Skip to content

Commit

Permalink
Document details of v-type ltcmd argument
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Jun 14, 2023
1 parent a64deae commit 8d9bc2a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ are not part of the distribution.
* ltcmd.dtx
Collect spaces and tabs as active chars
Collect \endlinechar as \par
* usrguide.tex
Add more details of ltcmd v-type arguments

2023-06-09 Joseph Wright <Joseph.Wright@latex-project.org>

Expand Down
36 changes: 36 additions & 0 deletions base/doc/usrguide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,42 @@ \subsection{Commands at the start of tabular cells}
\end{tabular}
\end{verbatim}

\subsection{Using the verbatim argument types}

As described about, the \texttt{v}-type argument may be viewed as similar to
\cs{verb}. Before looking at exactly what that means, it is important to
highlight some key differences. Note that using the \texttt{v}-type argument
does require knowledge of underlying \TeX{} concepts, in particular
category codes.

In contrast to \cs{verb}, the \texttt{v}-type argument is only about
\emph{grabbing} the argument, not \emph{typesetting} it. As such, features that
users often associate with \enquote{verbatim} are not automatically activated,
e.g.~a monospaced font. Material grabbed by the \texttt{v}-type argument does
not automatically suppress ligatures: with modern \TeX{} engines, this largely
can be done without the token manipulation which \cs{verb} uses.

When grabbing a \texttt{v}-type argument, \LaTeX{} first uses the kernel
command \cs{dospecials} to change the category code of special characters to
\enquote{other}. It then makes both spaces and tabs active, and leaves the
category code of other characters unchanged. Tokens are then grabbed between
two identical delimiters: in contract to \cs{verb}, the characters
\texttt{\textbackslash}, |{|, |}| and |%| \emph{cannot be used}. If any of the
grabbed tokens do not have category code space~(10), letter~(11),
\enquote{other}~(12) or active~(13), an error will be issued: as such, any
non-standard character tokens must be listed in \cs{dospecials}.

After grabbing, all non-active character tokens are converted to
\enquote{other} tokens. Spaces and tabs \emph{are stored as
active tokens}, as are other document-level active characters. This
allows the use of UTF-8 material in \texttt{v}-type arguments with
pdf\TeX{}.

For the \texttt{+v}-type argument, which allows line breaks in input,
newline characters are converted into \cs{par} tokens. This means that
the grabbed tokens can be used directly in typesetting, while a local
redefinition of \cs{par} can be used to achieve other outputs.

\subsection{Details about argument delimiters}

In normal (non-expandable) commands, the delimited types look for the
Expand Down

0 comments on commit 8d9bc2a

Please sign in to comment.