I am trying to understand how commands are typeset for use in LaTeX documentation. To clarify, not using LaTeX to create documentation, rather to write documentation in LaTeX about using LaTeX (like in the manuals). As far as I am aware, there is no term of this to distinguish LaTeX documentation from creating documentation with LaTeX (unfortunately).
Lines 1099-1121 of the pgfmanual-en-macros.tex
https://www.ctan.org/pkg/pgf?lang=en
This code “looks like” it removes at signs to me, but I don’t know. Why is this necessary? How does it work?
{
makeatletter
globalletmyempty=@empty
globalletmygobble=@gobble
catcode`@=12
gdefgetridofats#1@#2relax{%
defgetridtest{#2}%
ifxgetridtestmyempty%
expandafterdefexpandafterstrippedatexpandafter{strippedat#1}
else%
expandafterdefexpandafterstrippedatexpandafter{strippedat#1protectprintanat}
getridofats#2relax%
fi%
}
gdefremoveats#1{%
letstrippedatmyempty%
edefstrippedtext{stripcommand#1}%
expandaftergetridofatsstrippedtext @relax%
}
gdefstripcommand#1{expandaftermygobblestring#1}
}
Reasoning
The reason why I would like to understand this is because I seem to be able to typeset commands with the following code. I suspect there are cases when the my idea will not work.
There are also limitations:
- include commands with arguments such that I can typeset them (in
NewEnviron
with#1
) as an example under the explanation (e.g. hello{input1} and then using#1
in theNewEnviron
would not work)
documentclass{article}
usepackage{fontspec}
usepackage{environ}
NewEnviron{command}[1]{%
begin{minipage}[t]{.3textwidth}
texttt{string#1}
end{minipage}
hfill
begin{minipage}[t]{.7textwidth}
BODY
end{minipage}
xdefputcommandexample{BODY}% Set BODY to variable http://tex.stackexchange.com/a/14392/13552
}%
begin{document}
section{Friendly Commands}
begin{command}{hello}
This command greets the reader in a friendly manner.
end{command}
begin{command}{goodbye}
This command greets the reader in a friendly manner.
end{command}
end{document}
Sidenote for anybody interested: Instead of minipage
s I also put the commands in the margin using the marginnote
package. It looks alright.
NewEnviron{command}[1]{%
reversemarginparmarginnote{texttt{string#1}}
BODY
par
}%