Take account of change from tcrfenum to crossrefenum

This commit is contained in:
Bastien Dumont 2022-11-06 21:51:12 +01:00
parent ac7abe5ef0
commit aeb693793b
5 changed files with 56 additions and 56 deletions

View File

@ -22,7 +22,7 @@ In LibreOffice, press `F9`; in Word, a dialog box should appear when the file op
### TeX-based formats
All references are wrapped in a macro named `\tcrfenum`.
All references are wrapped in a macro named `\crossrefenum`.
It has two optional arguments:
the first one is the reference type,
the second indicates whether the prefix (e.g. “p. ”) should be printed or not
@ -30,26 +30,26 @@ the second indicates whether the prefix (e.g. “p. ”) should be printed or
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 enclosing one or more groups.
The mandatory argument of `\crossrefenum` is a group enclosing one or more groups.
Each of them contain a reference (either a single reference or a range).
Here are some valid invocations:
* `\tcrfenum[note][withprefix]{{lblone}{lbltwo}{lblthree}}`
* `\tcrfenum[page][noprefix]{{lblone}{lbltwo}{lblthree}}`
* `\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 in a group)
* `\tcrfenum{{lblone to lbltwo}{lblthree}}` (the first reference points to a range)
* `\crossrefenum[note][withprefix]{{lblone}{lbltwo}{lblthree}}`
* `\crossrefenum[page][noprefix]{{lblone}{lbltwo}{lblthree}}`
* `\crossrefenum[noprefix]{{lblone}{lbltwo}{lblthree}}` (the first argument defaults to `page`)
* `\crossrefenum{{lblone}{lbltwo}{lblthree}}` (the second argument defaults to `withprefix`)
* `\crossrefenum{{only-one}}` (even if the enumeration is limited to one item, it must be in a group)
* `\crossrefenum{{lblone to lbltwo}{lblthree}}` (the first reference points to a range)
It is up to you to define `\tcrfenum` in your preamble.
It is up to you to define `\crossrefenum` 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 currently supports ConTeXt and LaTeX.
Here are some hints about the implementation of the `\tcrfenum` macro:
Here are some hints about the implementation of the `\crossrefenum` macro:
* [The `\tcrfenum` macro is supposed to output non only the numbers,
* [The `\crossrefenum` macro is supposed to output non only the numbers,
but also 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
@ -66,16 +66,16 @@ Here are some hints about the implementation of the `\tcrfenum` macro:
\catcode`\@=11
\let\origfootnote\footnote
\def\footnote#1#2{
\def\tcrf@secondArg{#2}%
\ifx\tcrf@secondArg\tcrf@bracket
\def\tcrf@todo{\tcrf@footnote@withlabel{#1}#2} %
\def\crfnm@secondArg{#2}%
\ifx\crfnm@secondArg\crfnm@bracket
\def\crfnm@todo{\crfnm@footnote@withlabel{#1}#2} %
\else
\def\tcrf@todo{\origfootnote{#1}#2}%
\def\crfnm@todo{\origfootnote{#1}#2}%
\fi
\tcrf@todo
\crfnm@todo
}
\def\tcrf@bracket{[}
\def\tcrf@footnote@withlabel#1[#2]{\origfootnote[#2]{#1}}
\def\crfnm@bracket{[}
\def\crfnm@footnote@withlabel#1[#2]{\origfootnote[#2]{#1}}
\catcode`\@=13
```
@ -110,9 +110,9 @@ opinion in [my-evaluation]{.tcrf reftype=note}, [my-evaluation]{.tcrf}.
will render in ConTeXt or LaTeX output:
``` tex
See \tcrfenum{{publication}} for the publication date. I expressed
my thoughts about it in \tcrfenum[note]{{my-evaluation}},
\tcrfenum{{my-evaluation}}.
See \crossrefenum{{publication}} for the publication date. I expressed
my thoughts about it in \crossrefenum[note]{{my-evaluation}},
\crossrefenum{{my-evaluation}}.
```
If you want to give a reference by note _and_ page number like in the example above,
@ -145,12 +145,12 @@ The separator (here `>`) can be set to any string of characters
other than alphanumeric, period, colon, underscore, hyphen and space
(see the [customization options](#common-opts)).
In LaTeX and ConTeXt output, the above-mentionned `\tcrfenum` macro
In LaTeX and ConTeXt output, the above-mentionned `\crossrefenum` 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[^customize-range-tex]:
``` tex
\tcrfenum{{publication to reception}}
\crossrefenum{{publication to reception}}
```
[^customize-range-tex]: Note that [it can be customized](#tex-options).
@ -168,11 +168,11 @@ You can enumerate several references as a comma-delimited list, for instance:
In DOCX and ODT/Opendocument output, all these references will be printed,
potentially resulting in unnecessary repetitions.
In TeX-based output formats, they will be wrapped in `\tcrfenum` like this
In TeX-based output formats, they will be wrapped in `\crossrefenum` like this
and should be collapsed by the macro when it is desirable:
``` tex
\tcrfenum{{ref-one}{ref-two to ref-three}{ref-four}}
\crossrefenum{{ref-one}{ref-two to ref-three}{ref-four}}
```
## Customization
@ -188,7 +188,7 @@ The following metadata fields can be set as strings:
* the string used to separate two references in a reference span;
* defaults to `>`.
* `tcrf-only-explicit-labels`:
* set it to `true` if you want _tcrfenum_ to refer to spans with class `label` only;
* set it to `true` if you want _crossrefenum_ to refer to spans with class `label` only;
* defaults to `false`.
* `tcrf-default-prefixref`:
* default value for the `prefixref` attribute;
@ -258,9 +258,9 @@ tcrf-additional-types:
Once declared, these types can be used as the value of `reftype`
in the same way as `page`, `note` and `pagenote`.
In addition, the following metadata field can be used to control the rendering of ranges of labels in `\tcrfenum`:
In addition, the following metadata field can be used to control the rendering of ranges of labels in `\crossrefenum`:
* `tcrf-range-delim-tcrfenum`:
* `tcrf-range-delim-crossrefenum`:
* the delimiter between the labels of a range in the TeX output file;
* defaults to `to` surrounded with spaces.

View File

@ -2,7 +2,7 @@
tcrf-pagenote-separator: '\ ('
tcrf-pagenote-at-end: ')'
header-includes: |
\input{tex-aux/tcrfenum}
\input{tex-aux/crossrefenum}
---
(About the notes, see [toc-notes-begin>toc-notes-end]{.tcrf}.)

View File

@ -11,7 +11,7 @@
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context")
"\\tcrfenum{{toc-notes-begin to toc-notes-end}}"
"\\crossrefenum{{toc-notes-begin to toc-notes-end}}"
]
, Str ".)"
]
@ -77,7 +77,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "context") "\\tcrfenum{{publication}}" ]
[ RawInline (Format "context") "\\crossrefenum{{publication}}" ]
, Space
, Str "for"
, Space
@ -104,7 +104,7 @@
, Span
( "" , [ "tcrf" ] , [ ( "reftype" , "pagenote" ) ] )
[ RawInline
(Format "context") "\\tcrfenum[pagenote]{{my-evaluation}}"
(Format "context") "\\crossrefenum[pagenote]{{my-evaluation}}"
]
, Str "."
]
@ -131,7 +131,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context") "\\tcrfenum{{publication to reception}}"
(Format "context") "\\crossrefenum{{publication to reception}}"
]
, Str "."
]
@ -255,7 +255,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context") "\\tcrfenum{{refer-to-note}}"
(Format "context") "\\crossrefenum{{refer-to-note}}"
]
, Str "."
]
@ -275,7 +275,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "context") "\\tcrfenum{{format}}" ]
[ RawInline (Format "context") "\\crossrefenum{{format}}" ]
, Str "."
]
]
@ -305,7 +305,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context") "\\tcrfenum{{which-identifier}}"
(Format "context") "\\crossrefenum{{which-identifier}}"
]
, Str "."
]
@ -338,7 +338,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context") "\\tcrfenum{{nested-spans}}"
(Format "context") "\\crossrefenum{{nested-spans}}"
]
, Str "."
]
@ -358,7 +358,7 @@
( "" , [ "tcrf" ] , [ ( "reftype" , "note" ) ] )
[ RawInline
(Format "context")
"\\tcrfenum[note]{{my-evaluation}{format}{refer-to-note}}"
"\\crossrefenum[note]{{my-evaluation}{format}{refer-to-note}}"
]
]
]
@ -377,7 +377,7 @@
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "context")
"\\tcrfenum{{my-evaluation}{format}}"
"\\crossrefenum{{my-evaluation}{format}}"
]
]
]

View File

@ -11,7 +11,7 @@
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "latex")
"\\tcrfenum{{toc-notes-begin to toc-notes-end}}"
"\\crossrefenum{{toc-notes-begin to toc-notes-end}}"
]
, Str ".)"
]
@ -77,7 +77,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "latex") "\\tcrfenum{{publication}}" ]
[ RawInline (Format "latex") "\\crossrefenum{{publication}}" ]
, Space
, Str "for"
, Space
@ -104,7 +104,7 @@
, Span
( "" , [ "tcrf" ] , [ ( "reftype" , "pagenote" ) ] )
[ RawInline
(Format "latex") "\\tcrfenum[pagenote]{{my-evaluation}}"
(Format "latex") "\\crossrefenum[pagenote]{{my-evaluation}}"
]
, Str "."
]
@ -131,7 +131,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "latex") "\\tcrfenum{{publication to reception}}"
(Format "latex") "\\crossrefenum{{publication to reception}}"
]
, Str "."
]
@ -254,7 +254,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "latex") "\\tcrfenum{{refer-to-note}}"
[ RawInline (Format "latex") "\\crossrefenum{{refer-to-note}}"
]
, Str "."
]
@ -274,7 +274,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "latex") "\\tcrfenum{{format}}" ]
[ RawInline (Format "latex") "\\crossrefenum{{format}}" ]
, Str "."
]
]
@ -304,7 +304,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "latex") "\\tcrfenum{{which-identifier}}"
(Format "latex") "\\crossrefenum{{which-identifier}}"
]
, Str "."
]
@ -336,7 +336,7 @@
, Space
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline (Format "latex") "\\tcrfenum{{nested-spans}}"
[ RawInline (Format "latex") "\\crossrefenum{{nested-spans}}"
]
, Str "."
]
@ -356,7 +356,7 @@
( "" , [ "tcrf" ] , [ ( "reftype" , "note" ) ] )
[ RawInline
(Format "latex")
"\\tcrfenum[note]{{my-evaluation}{format}{refer-to-note}}"
"\\crossrefenum[note]{{my-evaluation}{format}{refer-to-note}}"
]
]
]
@ -374,7 +374,7 @@
, Span
( "" , [ "tcrf" ] , [] )
[ RawInline
(Format "latex") "\\tcrfenum{{my-evaluation}{format}}"
(Format "latex") "\\crossrefenum{{my-evaluation}{format}}"
]
]
]

View File

@ -5,27 +5,27 @@ assert(#refs == 1)
assert(refs[1].anchor == 'mylabel')
assert(not refs[1].end_of_range)
assert(make_raw_content_tex(refs, 'page', true)
== '\\tcrfenum{{mylabel}}')
== '\\crossrefenum{{mylabel}}')
assert(make_raw_content_tex(refs, 'page', false)
== '\\tcrfenum[noprefix]{{mylabel}}')
== '\\crossrefenum[noprefix]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', true)
== '\\tcrfenum[note]{{mylabel}}')
== '\\crossrefenum[note]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', false)
== '\\tcrfenum[note][noprefix]{{mylabel}}')
== '\\crossrefenum[note][noprefix]{{mylabel}}')
refs = parse_references_enum('rangebeg>rangeend')
assert(#refs == 1)
assert(refs[1].anchor == 'rangebeg')
assert(refs[1].end_of_range == 'rangeend')
assert(make_raw_content_tex(refs, 'page', true)
== '\\tcrfenum{{rangebeg to rangeend}}')
== '\\crossrefenum{{rangebeg to rangeend}}')
refs = parse_references_enum('first, second')
assert(#refs == 2)
assert(refs[1].anchor == 'first')
assert(refs[2].anchor == 'second')
assert(make_raw_content_tex(refs, 'page', true)
== '\\tcrfenum{{first}{second}}')
== '\\crossrefenum{{first}{second}}')
refs = parse_references_enum('first, rangebeg>rangeend')
assert(#refs == 2)
@ -33,4 +33,4 @@ assert(refs[1].anchor == 'first')
assert(refs[2].anchor == 'rangebeg')
assert(refs[2].end_of_range == 'rangeend')
assert(make_raw_content_tex(refs, 'page', true)
== '\\tcrfenum{{first}{rangebeg to rangeend}}')
== '\\crossrefenum{{first}{rangebeg to rangeend}}')