0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Zotero の drag and drop をハックする ~ CSL ファイルの編集

Posted at

Zotero で管理している文献を、Zotero の画面から drag and drop すると、設定した文献スタイルに直した文字列を挿入することができる。
そのまま行うと Bibliography (論文の References で書く詳細な文献情報)のスタイル、Shift を推しながら行う Citation (論文の文章中、(Sato et al., 2025), [1] 等)のスタイルとなる。

このとき、申請書等への入力は既存のスタイル(例えば IEEE)で使いたい。
しかし、例えば発表スライド等で使いたい Citation スタイルが必ずしも良いとは限らない。

毎回選んでエクスポートすればよいのだが、面倒なのでそのまま使える自作の Cite Style Language ファイルを作った。
いじり方のメモも残す。
(なお、体系的な知識がなく、band-aid solution であるため、間違いやより良い方法があれば教えてほしいです。)

今回は、IEEE のスタイルをもとに、(Author, Journal, Year) の citation となるように作ってみた。

CSL の編集方法

Edit > Settings > Cite > Tools > Style Editor

また、
Edit > Settings > Cite > Tools > Style Preview
にてプレビューを見て逐一確認する。

簡単な理解

CSL ファイルには、CSL の情報、Macros、Citation、Bibliography が順に並んでいることが多い。

  • CSL の情報
    • 名前、CSL を検索するときのカテゴリー等
  • Macros
    • <macro name="MACRONAME"> で定義
    • 以下の Citation, Bibliography で <text macro="MACRONAME"> として使う
  • Citation
    • <citation>
    • 論文の文章中
    • (Sato et al., 2025), [1] 等
  • Bibliography
    • <bibliography>
    • 論文の References で書く詳細な文献情報

IEEE CSL から編集したこと

Citation

  <citation>
    <layout prefix="(" suffix=")" delimiter=", ">
      <text macro="author_short" suffix=", " />
      <text macro="container-title" suffix=", " />
      <text macro="issued" />
    </layout>
  </citation>
  • <layout> の下で入れたい情報を <text macro=...> で入れていく
  • ここで、author が三人以上の時に et al. を使いたかったので、author_short というマクロを作った

Macros

author_short

  <macro name="author_short">
    <names variable="author">
      <name and="text" et-al-min="3" et-al-use-first="1" initialize-with=". " />
      <label form="short" prefix=", " text-case="capitalize-first" />
      <et-al font-style="italic" />
      <substitute>
        <names variable="editor" />
        <names variable="translator" />
        <text macro="director" />
      </substitute>
    </names>
  </macro>

  • author の macro をコピペして、et-al-min をいじっただけ

Journal name

  <macro name="container-title">
    <choose>
      <if type="paper-conference">
        <text variable="event" font-style="italic" />
      </if>
      <else>
        <text variable="container-title" />
      </else>
    </choose>
  </macro>
  • 学会の proceeding のときに、デフォルトだと Journal 名がないので、学会名を入れられるようにした

CSL の情報

フォーマットに合うよう直す。

作った CSL

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
  <info>
    <title>IEEE (Author, Journal, Year)</title>
    <id>http://www.zotero.org/styles/ieee-author-journal-year</id>
    <link href="http://www.zotero.org/styles/ieee-author-journal-year" rel="self" />
    <author>
      <name>Yugo Inutsuka</name>
      <email>yugo.inutsuka@a.riken.jp</email>
    </author>
    <category citation-format="author-date" />
    <category field="engineering" />
    <category field="generic-base" />
    <summary>Modified IEEE style to display citations as (Author, Journal, Year).</summary>
    <updated>2025-01-17T14:30:00+00:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <locale xml:lang="en">
    <date form="text">
      <date-part name="month" form="short" suffix=" " />
      <date-part name="day" form="numeric-leading-zeros" suffix=", " />
      <date-part name="year" />
    </date>
    <terms>
      <term name="chapter" form="short">ch.</term>
      <term name="chapter-number" form="short">ch.</term>
      <term name="presented at">presented at the</term>
      <term name="available at">available</term>
    </terms>
  </locale>


  <!-- Macros -->
  <macro name="status">
    <choose>
      <if variable="page issue volume" match="none">
        <text variable="status" text-case="capitalize-first" suffix="" font-weight="bold" />
      </if>
    </choose>
  </macro>
  <macro name="edition">
    <choose>
      <if type="bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="any">
        <choose>
          <if is-numeric="edition">
            <group delimiter=" ">
              <number variable="edition" form="ordinal" />
              <text term="edition" form="short" />
            </group>
          </if>
          <else>
            <text variable="edition" text-case="capitalize-first" suffix="." />
          </else>
        </choose>
      </if>
    </choose>
  </macro>
  <macro name="issued">
    <choose>
      <if type="article-journal report" match="any">
        <date variable="issued">
          <date-part name="month" form="short" suffix=" " />
          <date-part name="year" form="long" />
        </date>
      </if>
      <else-if type="bill book chapter graphic legal_case legislation song thesis" match="any">
        <date variable="issued">
          <date-part name="year" form="long" />
        </date>
      </else-if>
      <else-if type="paper-conference" match="any">
        <date variable="issued">
          <date-part name="month" form="short" />
          <date-part name="year" prefix=" " />
        </date>
      </else-if>
      <else-if type="motion_picture" match="any">
        <date variable="issued" form="text" prefix="(" suffix=")" />
      </else-if>
      <else>
        <date variable="issued" form="text" />
      </else>
    </choose>
  </macro>
  <macro name="author_short">
    <names variable="author">
      <name and="text" et-al-min="3" et-al-use-first="1" initialize-with=". " />
      <label form="short" prefix=", " text-case="capitalize-first" />
      <et-al font-style="italic" />
      <substitute>
        <names variable="editor" />
        <names variable="translator" />
        <text macro="director" />
      </substitute>
    </names>
  </macro>
  <macro name="author">
    <names variable="author">
      <name and="text" et-al-min="7" et-al-use-first="1" initialize-with=". " />
      <label form="short" prefix=", " text-case="capitalize-first" />
      <et-al font-style="italic" />
      <substitute>
        <names variable="editor" />
        <names variable="translator" />
        <text macro="director" />
      </substitute>
    </names>
  </macro>
  <macro name="editor">
    <names variable="editor">
      <name initialize-with=". " delimiter=", " and="text" />
      <label form="short" prefix=", " text-case="capitalize-first" />
    </names>
  </macro>
  <macro name="director">
    <names variable="director">
      <name and="text" et-al-min="7" et-al-use-first="1" initialize-with=". " />
      <et-al font-style="italic" />
    </names>
  </macro>
  <macro name="locators">
    <group delimiter=", ">
      <text macro="edition" />
      <group delimiter=" ">
        <text term="volume" form="short" />
        <number variable="volume" form="numeric" />
      </group>
      <group delimiter=" ">
        <number variable="number-of-volumes" form="numeric" />
        <text term="volume" form="short" plural="true" />
      </group>
      <group delimiter=" ">
        <text term="issue" form="short" />
        <number variable="issue" form="numeric" />
      </group>
    </group>
  </macro>
  <macro name="title">
    <choose>
      <if type="bill book graphic legal_case legislation motion_picture song standard software" match="any">
        <text variable="title" font-style="italic" />
      </if>
      <else>
        <text variable="title" quotes="true" />
      </else>
    </choose>
  </macro>
  <macro name="publisher">
    <choose>
      <if type="bill book chapter graphic legal_case legislation motion_picture paper-conference song" match="any">
        <group delimiter=": ">
          <text variable="publisher-place" />
          <text variable="publisher" />
        </group>
      </if>
      <else>
        <group delimiter=", ">
          <text variable="publisher" />
          <text variable="publisher-place" />
        </group>
      </else>
    </choose>
  </macro>
  <macro name="event">
    <choose>
      <!-- Published Conference Paper -->
      <if type="paper-conference speech" match="any">
        <choose>
          <if variable="container-title" match="any">
            <group delimiter=" ">
              <text term="in" />
              <text variable="container-title" font-style="italic" />
            </group>
          </if>
          <!-- Unpublished Conference Paper -->
          <else>
            <group delimiter=" ">
              <text term="presented at" />
              <text variable="event" />
            </group>
          </else>
        </choose>
      </if>
    </choose>
  </macro>
  <macro name="access">
    <choose>
      <if type="webpage post post-weblog" match="any">
        <!-- https://url.com/ (accessed Mon. DD, YYYY). -->
        <choose>
          <if variable="URL">
            <group delimiter=". " prefix=" ">
              <group delimiter=": ">
                <text term="accessed" text-case="capitalize-first" />
                <date variable="accessed" form="text" />
              </group>
              <text term="online" prefix="[" suffix="]" text-case="capitalize-first" />
              <group delimiter=": ">
                <text term="available at" text-case="capitalize-first" />
                <text variable="URL" />
              </group>
            </group>
          </if>
        </choose>
      </if>
      <else-if match="any" variable="DOI">
        <!-- doi: 10.1000/xyz123. -->
        <text variable="DOI" prefix=" doi: " suffix="." />
      </else-if>
      <else-if variable="URL">
        <!-- Accessed: Mon. DD, YYYY. [Medium]. Available: https://URL.com/ -->
        <group delimiter=". " prefix=" " suffix=". ">
          <!-- Accessed: Mon. DD, YYYY. -->
          <group delimiter=": ">
            <text term="accessed" text-case="capitalize-first" />
            <date variable="accessed" form="text" />
          </group>
          <!-- [Online Video]. -->
          <group prefix="[" suffix="]" delimiter=" ">
            <choose>
              <if variable="medium" match="any">
                <text variable="medium" text-case="capitalize-first" />
              </if>
              <else>
                <text term="online" text-case="capitalize-first" />
                <choose>
                  <if type="motion_picture">
                    <text term="video" text-case="capitalize-first" />
                  </if>
                </choose>
              </else>
            </choose>
          </group>
        </group>
        <!-- Available: https://URL.com/ -->
        <group delimiter=": " prefix=" ">
          <text term="available at" text-case="capitalize-first" />
          <text variable="URL" />
        </group>
      </else-if>
    </choose>
  </macro>
  <macro name="page">
    <choose>
      <if type="article-journal" variable="number" match="all">
        <group delimiter=" ">
          <text value="Art." />
          <text term="issue" form="short" />
          <text variable="number" />
        </group>
      </if>
      <else>
        <group delimiter=" ">
          <label variable="page" form="short" />
          <text variable="page" />
        </group>
      </else>
    </choose>
  </macro>
  <macro name="citation-locator">
    <group delimiter=" ">
      <choose>
        <if locator="page">
          <label variable="locator" form="short" />
        </if>
        <else>
          <label variable="locator" form="short" text-case="capitalize-first" />
        </else>
      </choose>
      <text variable="locator" />
    </group>
  </macro>
  <macro name="geographic-location">
    <group delimiter=", " suffix=".">
      <choose>
        <if variable="publisher-place">
          <text variable="publisher-place" text-case="title" />
        </if>
        <else-if variable="event-place">
          <text variable="event-place" text-case="title" />
        </else-if>
      </choose>
    </group>
  </macro>
  <macro name="container-title">
    <choose>
      <if type="paper-conference">
        <text variable="event" font-style="italic" />
      </if>
      <else>
        <text variable="container-title" />
      </else>
    </choose>
  </macro>

  <!-- Series -->
  <macro name="collection">
    <choose>
      <if variable="collection-title" match="any">
        <text term="in" suffix=" " />
        <group delimiter=", " suffix=". ">
          <text variable="collection-title" />
          <text variable="collection-number" prefix="no. " />
          <text variable="volume" prefix="vol. " />
        </group>
      </if>
    </choose>
  </macro>


  <!-- Citation -->
  <citation et-al-min="4" et-al-use-first="1">
    <layout prefix="(" suffix=")" delimiter=", ">
      <text macro="author_short" suffix=", " />
      <text macro="container-title" suffix=", " />
      <text macro="issued" />
    </layout>
  </citation>


  <!-- Bibliography -->
  <bibliography entry-spacing="0" second-field-align="flush">
    <layout>
      <!-- Citation Number -->
      <text variable="citation-number" prefix="[" suffix="]" />
      <!-- Author(s) -->
      <text macro="author" suffix=", " />
      <!-- Rest of Citation -->
      <choose>
        <!-- Specific Formats -->
        <if type="article-journal">
          <group delimiter=", ">
            <text macro="title" />
            <text variable="container-title" font-style="italic" form="short" />
            <text macro="locators" />
            <text macro="page" />
            <text macro="issued" />
            <text macro="status" />
          </group>
          <choose>
            <if variable="URL DOI" match="none">
              <text value="." />
            </if>
            <else>
              <text value="," />
            </else>
          </choose>
          <text macro="access" />
        </if>
        <else-if type="paper-conference speech" match="any">
          <group delimiter=", " suffix=", ">
            <text macro="title" />
            <text macro="event" />
            <text macro="editor" />
          </group>
          <text macro="collection" />
          <group delimiter=", " suffix=".">
            <text macro="publisher" />
            <text macro="issued" />
            <text macro="page" />
            <text macro="status" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="chapter">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <group delimiter=" ">
              <text term="in" suffix=" " />
              <text variable="container-title" font-style="italic" />
            </group>
            <text macro="locators" />
            <text macro="editor" />
            <text macro="collection" />
            <text macro="publisher" />
            <text macro="issued" />
            <group delimiter=" ">
              <label variable="chapter-number" form="short" />
              <text variable="chapter-number" />
            </group>
            <text macro="page" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="report">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text macro="publisher" />
            <group delimiter=" ">
              <text variable="genre" />
              <text variable="number" />
            </group>
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="thesis">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text variable="genre" />
            <text macro="publisher" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="software">
          <group delimiter=". " suffix=".">
            <text macro="title" />
            <text macro="issued" prefix="(" suffix=")" />
            <text variable="genre" />
            <text macro="publisher" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="article">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text macro="issued" />
            <group delimiter=": ">
              <text macro="publisher" font-style="italic" />
              <text variable="number" />
            </group>
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="webpage post-weblog post" match="any">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text variable="container-title" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="patent">
          <group delimiter=", ">
            <text macro="title" />
            <text variable="number" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <!-- Online Video -->
        <else-if type="motion_picture">
          <text macro="geographic-location" suffix=". " />
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="standard">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <group delimiter=" ">
              <text variable="genre" />
              <text variable="number" />
            </group>
            <text macro="geographic-location" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <!-- Generic/Fallback Formats -->
        <else-if type="bill book graphic legal_case legislation report song" match="any">
          <group delimiter=", " suffix=". ">
            <text macro="title" />
            <text macro="locators" />
          </group>
          <text macro="collection" />
          <group delimiter=", " suffix=".">
            <text macro="publisher" />
            <text macro="issued" />
            <text macro="page" />
          </group>
          <text macro="access" />
        </else-if>
        <else-if type="article-magazine article-newspaper broadcast interview manuscript map patent personal_communication song speech thesis webpage" match="any">
          <group delimiter=", " suffix=".">
            <text macro="title" />
            <text variable="container-title" font-style="italic" />
            <text macro="locators" />
            <text macro="publisher" />
            <text macro="page" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else-if>
        <else>
          <group delimiter=", " suffix=". ">
            <text macro="title" />
            <text variable="container-title" font-style="italic" />
            <text macro="locators" />
          </group>
          <text macro="collection" />
          <group delimiter=", " suffix=".">
            <text macro="publisher" />
            <text macro="page" />
            <text macro="issued" />
          </group>
          <text macro="access" />
        </else>
      </choose>
    </layout>
  </bibliography>
</style>

付録:文献スタイルの設定

Edit > Settings > Export > Item Format

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?