csl

Syntax to detect the first occurrence of an in-text citation


I am trying to create a CSL file that uses the author names on the first in-text citation but contributor names on all subsequent citations (unless there is no contributor). What condition do I test for in the cs:if block to achieve this?

The following is a snippet of the citation section of my CSL.

<citation>
  <sort />
  <layout>
    <choose>
      <!-- I need assistance getting the condition for the next line -->
      <if match="CONDITIONAL FOR FIRST IN-TEXT CITATION">
        <text macro="author-short"/>
      </if>
      <else>
        <choose>
          <!-- 
            Use the contributor for subsequent citations if a contributor exists
            else use the short-author.
          -->
          <if match="any" variable="contributor">
            <text macro="author-contrib"/>
          </if>
          <else>
            <text macro="author-short"/>
          </else>
        </choose>
      </else>
    </choose>
  </layout>
</citation>

Solution

  • The position property is exactly designed for this, so in the context of your example:

    <if position="first">
        <text macro="author-short"/>
    </if>