When opening for the first time a file produced by Pandoc with text-crossrefs, you probably will have to refresh the fields in order to get the correct values. In LibreOffice, press `F9`; in Word, a dialog box should appear when the file opens.
### TeX-based formats
All references are wrapped in a macro named `\tcrfenum`. It has two optional arguments: the first one is the reference type, the second specifies whether the prefix (e.g.“p. ”) should be printed or not (can be set to `withprefix`, `noprefix`, `yes` or `no`). The default values for these arguments should match those of `tcrf-default-reftype` and `tcrf-default-prefixref` (resp.`page` and `yes`, i.e.`withprefix`). The mandatory argument of `\tcrfenum` is a group containing a list of groups. Each of them contain a reference (either a single reference or a range). Here are some valid invocations:
* \tcrfenum\[noprefix\]{{lblone}{lbltwo}{lblthree}} (the first argument defaults to `page`)
* \tcrfenum{{lblone}{lbltwo}{lblthree}} (the second argument defaults to `withprefix`)
* \tcrfenum{{only-one}} (even if the enumeration is limited to one item, it must be inside its own group)
* \tcrfenum{{lblone to lbltwo}{lblthree}} (the first reference points to a range)
It is up to you to define `\tcrfenum` in your preamble. If your target format is LaTeX, it should be possible to define it as a wrapper for the `\zcref` macro provided by [the zref-clever package](https://ctan.org/pkg/zref-clever). Alternatively, you can use [my implementation](TODO), which supports ConTeXt, LaTeX and other formats. Here are some hints about the implementation:
* [The `\tcrfenum` macro is supposed to output the numbers along with the prefixes and delimiters (e.g.“p. ” and “–”)]{#prefixes-tex};
* In ConTeXt, there is no way to retrieve the note number from a `\reference` or a `\pagereference` contained in the note as is customary in LaTeX. to work around this, footnotes are labelled automatically with the first identifier attached to a span in the note prefixed with `note:`. Contrary to the ConTeXt syntax, this label is placed _after_ the footnote content, which implies redefining the `\footnote` macro. If your template includes the `header-includes` metadata variable like in the default template, this redefinition will happen automatically. Otherwise, you can copy-paste the following code in your preamble:
To suppress the prefixes (e.g.“p. ”), you can set the `prefixref` attribute to `no` (defaults to `yes`). It can be useful, for instance, for small manually formatted indexes[^1]:
In LaTeX and ConTeXt output, the above-mentionned `\tcrfenum` macro should be defined so that the range is printed as a simple page reference if the page numbers are identical. The syntax of a range is:
``` tex
\tcrfenum{{publication to reception}}
```
In DOCX and ODT/Opendocument output, the same result can be achieved in a word processor by automatically searching and replacing duplicates with regular expressions and/or macros.
* the string between two references in an enumeration in a reference span; can be composed of any characters not authorized in an identifier;
* defaults to `, ` (with a space after the comma).
*`tcrf-references-range-separator`:
* the string used to separate two references in a reference span; can be composed of any characters not authorized in an identifier;
* defaults to `>`.
*`tcrf-only-explicit-labels`:
* set it to `true` if you want that _tcrf_ handle only spans with class `label`;
* defaults to `false`.
*`tcrf-default-prefixref`:
* default value for the `prefixref` attribute;
* defaults to `yes`.
*`tcrf-default-reftype`:
* default value for the `reftype` attribute;
* defaults to `page`.
*`tcrf-filelabel-ref-separator`:
* only useful in conjunction with the text-exrefs filter;
* separator between external files' labels and references;
* defaults to `::`.
### Options specific to DOCX and ODT/Opendocument
Here are some metadata fields only useful in conjunction with `docx`, `odt` and `opendocument` formats (see [above](#prefixes-tex) why they are ignored with `context` and `latex`):
* defaults to the empty string, can be used to achieve something like *n.3 (p.5)*.
*`tcrf-pagenote-factorize-first-prefix-in-enum`:
* defines if the prefixes of the type printed first in a reference to page and note should be repeated (e.g.“p.6, n.1 and p.9, n.3”) or expressed globally at the beginning of the enumeration (e.g.“pp.6, n.1 and 9, n.3”);
* defaults to `no`, can be set to `yes`.
*`tcrf-pagenote-first-type`:
* the information that is printed first in references to page and note;
Since TeX is extensible, you may wish to support types other than `page`, `note` and `pagenote` for ConTeXt and LaTeX output. `tcrf-additional-types` can be provided with a list of supplementary accepted types, e.g.:
``` yaml
tcrf-additional-types:
- line
- figure
```
In addition, the following metadata field can be used to control the rendering of ranges of labels in `\tcrfenum`:
*`tcrf-range-delim-tcrfenum`:
* the delimiter between the labels of a range in the list of references passed to `\tcrfenum`;
Text-crossrefs must be run after all other filters that can create, delete or move
footnotes, like citeproc.
In order to give and identifier to a note produced by a citation inside square brackets, the span should not include the citation key, the locator or the `;`
delimiter. If it is placed immediatly after the locator, this should be surrounded by curly brackets. So this should work:
``` markdown
[@Jones1973, p. 5-70; @Doe2004[]{#jones-doe}]
[@Jones1973, p. 5-70; [it was elaborated upon]{#further-elaboration} by @Doe2004]
You can set classes and attributes to your spans other than those defined by text-crossrefs (for instance `[some text]{#to-be-referred-to .highlighted color=red}` or `[reference]{.tcrf color=red}`). No span is removed.
Text-crossrefs is fully compatible with text-extrefs. Whenever possible, when a metadata is not set for text-extrefs, its value is taken from its text-crossrefs equivalent, so that you don't need to duplicate similar variables.