Debian Codegraph @

texmf-dist/doc/latex/enverb/doc-enverb.tex

raw
1 \subsection{Grabbing an Environment Verbatim}
2 \begin{function}{\enverb}
3 \begin{syntax}
4 \cs{enverb}\marg{key=value}\oarg{key=value}
5 \cs{enverb}\meta{*}\marg{key=value}
6 \end{syntax}
7 This function will store the contents of the enclosing environment verbatim
8 inside of \cs{enverbBody}. It should be the last thing you invoke inside the
9 |\begin| code of your environment and mustn't be enclosed in any nested
10 environment. Both the mandatory and the optional \meta{key=value} argument are
11 parsed by \cs{enverb} -- see \autoref{sec:keys} about the specifics of this.
12 The mandatory argument is meant for a package/code developer to assign the
13 sensible default values for the envisioned functionality and always parsed
14 inside the keyset of \cs{enverb}, while the optional one is meant to be used
15 by the user and as such should be the first thing inside the enclosing
16 environment (if the user wants to use an optional argument).\par
17 \cs{enverb} sets the special characters
18 \begingroup
19 \def\do#1%
20 {%
21 \ifx\ #1\else
22 , \texttt{\csname @gobble\expandafter\endcsname\string#1}%
23 \fi
24 }%
25 \csname @secondoftwo\expandafter\endcsname\romannumeral`\^^@\dospecials
26 \endgroup
27 \ to the category code 12 (other), and makes both spaces and tabulators active
28 tokens. By default each line break will be a category code 12 carriage return
29 (character code 13), but see the |eol| option in \autoref{sec:keys}.\par
30 A line that contains only whitespace on input will be output as an empty
31 line.\par
32 The \cs{enverb} syntax of the optional argument has a few peculiarities. It is
33 scanned for the opening bracket either on the same line as the |\begin|
34 statement of the enclosing environment, or on any subsequent line until a
35 non-whitespace character is found. The optional argument is read using the
36 \enquote{normal} (so surrounding) category code regime, but it is scanned for
37 it in a way that the first token is still read verbatim if no optional
38 argument was given.\par
39 The first non-whitespace token that's not an opening bracket must not be found
40 on the same line as the |\begin| statement, and if there was an optional
41 argument there shouldn't be any non-whitespace token trailing it in that line.
42 Additionally there should be no non-whitespace material following the |\end|
43 statement (anything preceding it in the same line is for the most part
44 ignored; |\begin| and |\end| are not balanced, the first |\end| with the
45 correct environment as argument terminates scanning).\par
46 The starred version of \cs{enverb} doesn't search for an optional argument.
47 \end{function}