Skip to main content

Module latex

Module latex 

Source
Expand description

The recomposition rule of the annotations feature on the latex-recomposed backend: an annotation is written back as the author wrote it, over the LaTeX package phfcc, which defines a reviewer’s commands.

writtenLaTeX
\phf{a passage}\phf{a passage}
\phf[a remark]\phf[a remark]
\phf a passage\endphf\phf a passage\endphf
\phf[one⏎⏎two]\phf[one⏎⏎two], one invocation

The rendering guide describes the same output for readers of the recomposed LaTeX (Annotations in the recomposed LaTeX).

§The invocation as written

The rule LATEX_RULE (AnnotationLatexRule) writes the command as it was written: the backslash and the name, and the whitespace that ended the name; then the whitespace and source comments written between the command and its opening { or [, the opening delimiter, the argument’s content lowered through the ordinary rules, and the closing delimiter: }, ], or \endphf with the whitespace it read. A passage that was not closed is written with no closing command, as it was written. The delimiters are the ones the argument’s group records (the annotation’s form is read from the same record), so that the three forms come back as the author typed them. The command, the whitespace after it and the delimiters are written as raw nodes (flm.pres.latex.raw, LaTeX text written byte for byte).

An annotation across a paragraph break is one invocation. The latex-recomposed backend lowers the tree before the block-structure pass, the pass that cuts an annotation into cut parts at its paragraph breaks and blocks. An annotation written across a paragraph break, or around a list, therefore reaches this rule as one node, with its paragraph breaks and blocks inside its argument, and is written back as typed: \phf[A comment.⏎⏎With more.] byte for byte, and phfcc colors the whole of it.

§The commands, made by phfcc

The rule requires the package request flm.latex.pkg.phfcc (packages::PHFCC, with no option; a LaTeX package that a rule requires by identifier, packages). It also writes into the style file, from the configuration, one declaration per configured annotator, in configuration order:

\ifcsname phf\endcsname\else\phfMakeCommentingCommand[initials={PhF}]{phf}\fi
\ifcsname abc\endcsname\else\phfMakeCommentingCommand[formatinitials=hide]{abc}\fi

The package assigns its colors in the order in which the commands are made, so the declarations follow the annotators’ numbers, the numbers by which the HTML stylesheet chooses its colors, and every configured annotator is declared, whether the document uses it or not. An annotator with initials passes them with the key initials, written as text; an annotator with none is made with formatinitials=hide, since the package would otherwise show the command’s name. Each declaration is guarded on the command it makes (LatexDefinitionKind::Declaration): where the author’s preamble already made a command of that name, that command is kept and the declaration does nothing. No LaTeX hook of the LaTeX family is involved: the package defines the commands.

§Output when every annotation is hidden

When AnnotationsRenderOptions::hidden is true, the rule writes no command, no package request and no declaration: a highlight lowers to its passage, and a comment to nothing but the paragraph breaks it held, so that the text around a comment written across a paragraph break remains two paragraphs. Hiding does not use the package’s own switch, \phfDisableCommentingCommands: that switch makes every use of a commenting command an error, for a final version that must contain none, whereas hiding leaves the text clean.

Structs§

AnnotationLatexRule
The implementation of the lowering rule LATEX_RULE, the default on the latex-recomposed backend: it writes an annotation back as the author wrote it, and stages the declarations of every configured annotator’s command for the style file. See the module documentation.

Constants§

LATEX_RULE
The name of the lowering rule of an annotation on the latex-recomposed backend, flm.annotations.annotation.lower.latex-recomposed (AnnotationLatexRule).
MAKE_COMMAND
The name of the command of the phfcc package that makes a reviewer’s commenting command, phfMakeCommentingCommand.

Functions§

latex_rule
Returns the lowering rule LATEX_RULE, the default on the latex-recomposed backend only, which declares the commands of annotators in the style file.