jgm / pandoc-citeproc

Library and executable for using citeproc with pandoc
BSD 3-Clause "New" or "Revised" License
291 stars 61 forks source link

Question: is it possible to suppress editor/translator in inline citation? #465

Closed bcdavasconcelos closed 3 years ago

bcdavasconcelos commented 4 years ago

Hi, let us say that I want to edit a CSL Style and set it up to display in the inline citation the editors (even if there is an author) or the translators. If I used the command to suppressed the author in the inline citation (-@citekey), would it work to suppress the editor or the translator as well?

I ask because I have tried this, but so far I could not get pandoc-citeproc to behave this way (even though it works fine in the Visual CSL Editor), which makes me wonder if this is possible at all or if I need to make some adjustment to the CSL style.

Thank you very much. Pandoc is amazing.

denismaier commented 4 years ago

Have you tried with Zotero? If it works in the Visual Editor, than it's most likely a bug in pandoc-citeproc. OTOH, it's hard to tell without actually seeing some code examples.

bcdavasconcelos commented 4 years ago

Hi, here is what I used to test this:

References

[
  {
    "author": [
      {
        "family": "Aristóteles"
      }
    ],
    "editor": [
      {
        "family": "Susemihl",
        "given": "Franz"
      },
      {
        "family": "Apelt",
        "given": "Otto"
      }
    ],
    "id": "EN_1903",
    "issued": {
      "date-parts": [
        [
          1903
        ]
      ]
    },
    "publisher": "Teubner",
    "publisher-place": "Leipzig",
    "title": "Ethica nicomachea",
    "type": "legislation"
  },
  {
    "author": [
      {
        "family": "Aristóteles"
      }
    ],
    "id": "EN_Irwin",
    "issued": {
      "date-parts": [
        [
          1999
        ]
      ]
    },
    "publisher": "Hackett",
    "publisher-place": "Indianápolis",
    "title": "Nicomachean ethics",
    "translator": [
      {
        "family": "Irwin",
        "given": "Terence"
      }
    ],
    "type": "report"
  },
  {
    "abstract": "EN",
    "annote": "EN",
    "author": [
      {
        "family": "Aristóteles"
      }
    ],
    "editor": [
      {
        "family": "Bekker",
        "given": "Immanuel"
      }
    ],
    "id": "EN",
    "issued": {
      "date-parts": [
        [
          1831
        ]
      ]
    },
    "page": "1094a01-1181b23",
    "publisher": "Reimer",
    "publisher-place": "Berlim",
    "title": "Ethica nicomachea",
    "type": "no-type",
    "volume": "Aristotelis Opera"
  }
]

Style

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text" demote-non-dropping-particle="never" default-locale="pt-BR">
  <info>
    <title>Associação Brasileira de Normas Técnicas (Portuguese - Brazil) - Bernardo Vasconcelos</title>
    <title-short>ABNT</title-short>
    <id>http://csl.mendeley.com/styles/597193711/ABNT-crazy</id>
    <link href="http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas" rel="self"/>
    <link href="https://forums.zotero.org/discussion/22148/how-to-apply-disambiguation-in-citation-just-when-works-of-different-authors-are-in-the-same-year/?Focus=147094#Comment_147094" rel="documentation"/>
    <author>
      <name>Juliana Geyna Régis</name>
      <email>juliana.regis@ipea.gov.br</email>
    </author>
    <contributor>
      <name>Lucas Mation</name>
      <email>lucas.mation@ipea.gov.br</email>
    </contributor>
    <contributor>
      <name>Eduardo Michelotti Bettoni</name>
      <email>webtur@ufpr.br</email>
    </contributor>
    <contributor>
      <name>Paulo Augusto Nascimento</name>
      <email>paulo.nascimento@ipea.gov.br</email>
    </contributor>
    <contributor>
      <name>Iuri Gavronski</name>
      <email>iuri at ufrgs dot br</email>
    </contributor>
    <contributor>
      <name>José Antonio Meira da Rocha</name>
      <email>joseantoniorocha@gmail.com</email>
      <uri>http://meiradarocha.jor.br</uri>
    </contributor>
    <contributor>
      <name>Mario José</name>
      <email>gnumario [at-mark] gmail [dot-mark] com</email>
    </contributor>
    <contributor>
      <name>Bernardo Vasconcelos</name>
      <uri>https://www.mendeley.com/profiles/bernardo-vasconcelos3/</uri>
    </contributor>
    <category citation-format="author-date"/>
    <category field="generic-base"/>
    <summary>The Brazilian Standard Style in accordance with ABNT-NBR 10520.2002 and ABNT-NBR 6023.2002</summary>
    <updated>2020-09-07T14:50:47+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="pt-BR">
    <terms>
      <term name="month-01" form="short">jan.</term>
      <term name="month-02" form="short">fev.</term>
      <term name="month-03" form="short">mar.</term>
      <term name="month-04" form="short">abr.</term>
      <term name="month-05" form="short">maio</term>
      <term name="month-06" form="short">jun.</term>
      <term name="month-07" form="short">jul.</term>
      <term name="month-08" form="short">ago.</term>
      <term name="month-09" form="short">set.</term>
      <term name="month-10" form="short">out.</term>
      <term name="month-11" form="short">nov.</term>
      <term name="month-12" form="short">dez.</term>
      <term name="editor" form="short">
        <single>ed</single>
        <multiple>eds</multiple>
      </term>
      <term name="container-author" form="short">
        <single>ed</single>
        <multiple>eds</multiple>
      </term>
      <term name="collection-editor" form="short">
        <single>ed</single>
        <multiple>eds</multiple>
      </term>
    </terms>
  </locale>
  <macro name="container-contributors">
    <choose>
      <if type="chapter">
        <names variable="container-author" delimiter=", ">
          <name name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
            <name-part name="family" text-case="uppercase"/>
            <name-part name="given" text-case="uppercase"/>
          </name>
          <label form="short" prefix=" (" suffix=".). " text-case="capitalize-first"/>
          <substitute>
            <names variable="editor"/>
            <names variable="collection-editor"/>
          </substitute>
        </names>
      </if>
    </choose>
  </macro>
  <macro name="secondary-contributors">
    <choose>
      <if type="chapter" match="none">
        <names variable="editor" delimiter="; " prefix=" (" suffix=")">
          <name initialize-with=". " delimiter=", "/>
          <label form="short" prefix=", " text-case="capitalize-first" suffix="."/>
        </names>
      </if>
    </choose>
  </macro>
  <macro name="translator">
    <names variable="translator" delimiter="; " prefix="Tradução: ">
      <name and="symbol" delimiter-precedes-last="after-inverted-name" sort-separator=" ">
        <name-part name="given" text-case="capitalize-first"/>
        <name-part name="family" text-case="capitalize-first"/>
      </name>
    </names>
  </macro>
  <macro name="author">
    <names variable="author">
      <name name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="always">
        <name-part name="family" text-case="uppercase"/>
        <name-part name="given" text-case="uppercase"/>
      </name>
      <label form="short" prefix=" (" suffix=".)" text-case="uppercase"/>
      <substitute>
        <names variable="editor"/>
        <names variable="translator"/>
        <text macro="title"/>
      </substitute>
    </names>
  </macro>
  <macro name="author-short">
    <choose>
      <if match="any" variable="annote">
        <text variable="annote" font-style="italic"/>
      </if>
      <else-if type="legislation" match="any">
        <names variable="editor" suffix=" ">
          <name form="short" and="symbol" delimiter-precedes-last="never" initialize-with="." name-as-sort-order="all">
            <name-part name="family" text-case="uppercase"/>
          </name>
          <substitute>
            <names variable="author">
              <name and="symbol">
                <name-part name="family" text-case="uppercase"/>
              </name>
            </names>
          </substitute>
        </names>
      </else-if>
      <else-if type="report" match="any">
        <names variable="translator" suffix=" ">
          <name form="short" and="symbol" delimiter-precedes-last="never" initialize-with="." name-as-sort-order="all">
            <name-part name="family" text-case="uppercase"/>
          </name>
          <substitute>
            <names variable="author">
              <name>
                <name-part name="family" text-case="uppercase"/>
              </name>
            </names>
          </substitute>
        </names>
      </else-if>
      <else>
        <names variable="author" suffix=" ">
          <name form="short" name-as-sort-order="all" sort-separator=", " initialize-with=". " delimiter="; " delimiter-precedes-last="never">
            <name-part name="family" text-case="uppercase"/>
            <name-part name="given" text-case="uppercase"/>
          </name>
          <substitute>
            <names variable="editor"/>
            <names variable="translator"/>
            <choose>
              <if type="book">
                <text variable="title" form="short"/>
              </if>
              <else>
                <text variable="title" form="short" quotes="true"/>
              </else>
            </choose>
          </substitute>
        </names>
      </else>
    </choose>
  </macro>
  <macro name="access">
    <text variable="URL" prefix="Disponível em: &lt;" suffix="&gt;"/>
    <date variable="accessed" prefix=". Acesso em: ">
      <date-part name="day" suffix=" "/>
      <date-part name="month" form="short" suffix=". " text-case="lowercase"/>
      <date-part name="year"/>
    </date>
  </macro>
  <macro name="title">
    <choose>
      <if type="chapter bill" match="any">
        <text variable="title"/>
      </if>
      <else-if type="book thesis" match="any">
        <text variable="title" font-weight="bold"/>
      </else-if>
      <else-if type="article-newspaper article-magazine article-journal" match="any">
        <text variable="title"/>
      </else-if>
      <else>
        <choose>
          <if match="all" variable="volume">
            <choose>
              <if match="none" is-numeric="volume">
                <text variable="title" quotes="true"/>
              </if>
            </choose>
          </if>
          <else>
            <text variable="title" font-weight="bold"/>
          </else>
        </choose>
      </else>
    </choose>
  </macro>
  <macro name="container-title">
    <choose>
      <if type="paper-conference" match="any">
        <text variable="container-title" suffix=". "/>
        <text value="Anais" font-weight="bold"/>
        <text value="..."/>
      </if>
      <else>
        <text variable="container-title" font-weight="bold"/>
      </else>
    </choose>
  </macro>
  <macro name="publisher">
    <choose>
      <if match="any" variable="publisher-place publisher">
        <choose>
          <if variable="publisher-place">
            <text variable="publisher-place" suffix=": "/>
          </if>
          <else-if type="entry-encyclopedia"/>
          <else>
            <text value="[s.l.] "/>
          </else>
        </choose>
        <choose>
          <if variable="publisher">
            <text variable="publisher" suffix=", "/>
            <text macro="issued"/>
          </if>
          <else>
            <text value="[s.n.]"/>
          </else>
        </choose>
      </if>
      <else>
        <text value="[s.l: s.n.]"/>
      </else>
    </choose>
  </macro>
  <macro name="event">
    <choose>
      <if variable="event">
        <choose>
          <if variable="genre" match="none">
            <text term="in" text-case="capitalize-first" suffix=": "/>
            <text variable="event" text-case="uppercase"/>
          </if>
          <else>
            <group delimiter=" ">
              <text variable="genre" text-case="capitalize-first"/>
              <text term="presented at"/>
              <text variable="event"/>
            </group>
          </else>
        </choose>
      </if>
    </choose>
  </macro>
  <macro name="issued">
    <choose>
      <if variable="issued" match="any">
        <group>
          <choose>
            <if type="book chapter" match="none">
              <date variable="issued">
                <date-part name="day" suffix=" "/>
                <date-part name="month" form="short" suffix=" "/>
              </date>
            </if>
          </choose>
          <date variable="issued">
            <date-part name="year"/>
          </date>
        </group>
      </if>
      <else>
        <text value="[s.d.]"/>
      </else>
    </choose>
  </macro>
  <macro name="issued-year">
    <choose>
      <if match="any" variable="annote"/>
      <else>
        <choose>
          <if variable="issued" match="any">
            <date variable="issued">
              <date-part name="year"/>
            </date>
          </if>
          <else>
            <text value="[s.d.]"/>
          </else>
        </choose>
      </else>
    </choose>
  </macro>
  <macro name="edition">
    <choose>
      <if type="book chapter" match="any">
        <choose>
          <if is-numeric="edition">
            <group delimiter=" ">
              <number variable="edition" form="numeric" suffix="."/>
              <text term="edition" form="short" suffix="."/>
            </group>
          </if>
          <else>
            <text variable="edition" suffix=" ed."/>
          </else>
        </choose>
      </if>
    </choose>
  </macro>
  <macro name="locators">
    <choose>
      <if type="bill">
        <group prefix=". " delimiter=", ">
          <date variable="issued">
            <date-part name="day"/>
            <date-part prefix=" " name="month" form="short"/>
            <date-part prefix=" " name="year"/>
          </date>
          <text variable="section" prefix="Sec. "/>
          <text variable="page" prefix="p. " suffix="."/>
        </group>
      </if>
      <else-if match="any" type="article-journal article-magazine article-newspaper">
        <group delimiter=", ">
          <group delimiter=", ">
            <text variable="volume" prefix="v. "/>
            <text variable="issue" prefix="n. "/>
          </group>
          <text variable="page" prefix="p. "/>
        </group>
      </else-if>
      <else-if match="any" type="book chapter">
        <group delimiter=", ">
          <group>
            <text variable="volume" prefix="v. "/>
            <text variable="page" prefix="p. "/>
          </group>
        </group>
      </else-if>
    </choose>
  </macro>
  <macro name="collection-title">
    <text variable="collection-title"/>
    <text variable="collection-number" prefix=" "/>
  </macro>
  <macro name="genre">
    <text variable="genre"/>
  </macro>
  <macro name="citation-locator">
    <group>
      <label form="short"/>
      <text variable="locator" prefix=" "/>
    </group>
  </macro>
  <macro name="place">
    <choose>
      <if match="any" variable="publisher-place">
        <text variable="publisher-place"/>
      </if>
    </choose>
  </macro>
  <macro name="archive">
    <group>
      <text variable="archive" prefix=" "/>
    </group>
  </macro>
  <citation et-al-min="4" et-al-use-first="1" collapse="year" disambiguate-add-year-suffix="true">
    <sort>
      <key macro="author"/>
      <key variable="issued"/>
    </sort>
    <layout prefix="(" suffix=")" delimiter="; ">
      <group>
        <text macro="author-short"/>
        <text macro="issued-year"/>
        <text prefix=", " macro="citation-locator"/>
      </group>
    </layout>
  </citation>
  <bibliography hanging-indent="false" et-al-min="4" et-al-use-first="1" entry-spacing="1">
    <sort>
      <key macro="author"/>
      <key variable="issued"/>
    </sort>
    <layout>
      <choose>
        <if type="bill">
          <group>
            <text macro="author" suffix=". "/>
            <text variable="number" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text variable="references" font-weight="bold"/>
            <text variable="note"/>
            <text macro="locators" suffix=". "/>
          </group>
        </if>
        <else-if type="map">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=", "/>
            <text macro="issued" suffix=". "/>
            <text variable="note" suffix=". "/>
          </group>
        </else-if>
        <else-if type="book report" match="any">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="translator" suffix=". "/>
            <text macro="edition" suffix=". "/>
            <text macro="publisher" suffix=". "/>
            <text macro="locators"/>
          </group>
        </else-if>
        <else-if type="chapter">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="secondary-contributors" suffix=". "/>
            <text term="in" text-case="capitalize-first" suffix=": "/>
            <text macro="container-contributors" suffix=". "/>
            <text macro="container-title" suffix=". "/>
            <text variable="collection-title" suffix=". "/>
            <text macro="translator" suffix=". "/>
            <text macro="edition" suffix=". "/>
            <text macro="publisher" suffix=". "/>
            <text macro="locators" suffix=". "/>
          </group>
        </else-if>
        <else-if type="article-newspaper article-magazine article-journal" match="any">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="container-title" suffix=", "/>
            <text variable="collection-title" suffix=". "/>
            <text macro="edition" suffix=", "/>
            <text macro="locators" suffix=", "/>
            <text macro="issued" suffix=". "/>
          </group>
        </else-if>
        <else-if type="thesis">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="genre" suffix="—"/>
            <text macro="publisher" suffix="."/>
          </group>
        </else-if>
        <else-if type="manuscript">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="edition" suffix=". "/>
            <text macro="place" suffix=", "/>
            <text macro="issued" suffix=". "/>
            <text macro="access" suffix=". "/>
            <text macro="archive" suffix=". "/>
          </group>
        </else-if>
        <else-if type="webpage">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title" suffix=". "/>
            <text macro="genre" suffix=". "/>
            <text macro="access" suffix=". "/>
          </group>
        </else-if>
        <else-if type="report">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title"/>
            <text macro="container-contributors"/>
            <text macro="secondary-contributors"/>
            <text macro="container-title"/>
            <text variable="collection-title" prefix=": "/>
            <text macro="locators"/>
            <text macro="event"/>
            <text macro="publisher" prefix=". " suffix=". "/>
            <text macro="access" suffix="."/>
          </group>
        </else-if>
        <else-if type="entry-dictionary">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title"/>
            <text macro="container-contributors"/>
            <text macro="secondary-contributors"/>
            <text macro="container-title"/>
            <text variable="collection-title" prefix=": " suffix=". "/>
            <text macro="locators"/>
            <text macro="event"/>
            <text macro="publisher" prefix=". " suffix=". "/>
            <text macro="collection-title" prefix="(Texto para discussao, n. " suffix=")."/>
            <text macro="access"/>
          </group>
        </else-if>
        <else-if type="entry-encyclopedia">
          <group>
            <text macro="author" suffix=". "/>
            <text macro="title"/>
            <text variable="publisher-place" prefix=". " suffix=": "/>
            <text variable="publisher" suffix=", "/>
            <text macro="issued" prefix=", " suffix=". (Nota técnica)."/>
          </group>
        </else-if>
        <else-if type="paper-conference">
          <text macro="author" suffix=". "/>
          <text macro="title" suffix=". "/>
          <text macro="container-contributors"/>
          <text macro="secondary-contributors"/>
          <text macro="container-title"/>
          <text variable="collection-title" prefix=": " suffix="."/>
          <text macro="locators"/>
          <group delimiter=". " prefix=". " suffix=". ">
            <text macro="event"/>
          </group>
          <text variable="publisher-place" suffix=": "/>
          <text variable="publisher" suffix=", "/>
          <text macro="issued"/>
          <text macro="access"/>
        </else-if>
        <else>
          <text macro="author" suffix=". "/>
          <text macro="title"/>
          <text macro="container-contributors"/>
          <text macro="secondary-contributors"/>
          <text macro="container-title"/>
          <text variable="collection-title" prefix=": " suffix="."/>
          <choose>
            <if match="any" variable="volume">
              <choose>
                <if match="any" is-numeric="volume">
                  <text variable="volume" prefix=" vol. "/>
                </if>
                <else>
                  <text variable="volume" font-weight="bold" prefix=" " suffix="."/>
                </else>
              </choose>
            </if>
          </choose>
          <text macro="locators"/>
          <group delimiter=". " prefix=". " suffix=". ">
            <text macro="event"/>
          </group>
          <text variable="publisher-place" prefix=" " suffix=":"/>
          <text variable="publisher" prefix=" "/>
          <text macro="issued" prefix=", " suffix=". "/>
          <text macro="access"/>
        </else>
      </choose>
    </layout>
  </bibliography>
</style>

Types

The type legislation is the one I am using for placing the editor in the inline citation. The type report is the one I am using for placing the translator in the inline citation. The no-type is the one I am using for placing the field annote in the inline citation.

(I would be using different types, but whenever I try to convert my bibtex file to json with Pandoc, it erases some types (e.g. broadcast, bill, webpage, etc) and turns them into no-type. But this is not really relevant to the matter at hand.)

I will check and see if I can get this to work in Zotero as well.

bcdavasconcelos commented 4 years ago

Just leaving a note to say that, in Zotero, if I check the Omit Author box in the style editor, it works as expected.

jgm commented 4 years ago

This works properly with my new citeproc library, which will replace pandoc-citeproc.

bcdavasconcelos commented 4 years ago

Thanks for the heads up, John @jgm. I just saw the repository. Looking forward to seeing it released!

jgm commented 4 years ago

Reopening for now, because I want to add the outstanding pandoc-citeproc test cases to the new version of pandoc that incorporates the citeproc library.

bcdavasconcelos commented 4 years ago

The new citeproc library in the latest Pandoc release works wonderfully. Thanks a lot, John @jgm.