UPDATE: I've opened a follow-up question: How can I typeset an environment and its literal equivalent in an environment?
I would like to pass a command and arguments to an environment. The output should be threefold:
- The literal command
- The typeset version (how it should appear when used)
- The definition of the command. (This is just a textual description of what the command is used for.)
My Attempt
For this example, I try to use the \key command provided by the menukeys package.
\documentclass{article}
\usepackage{fontspec}
\usepackage{environ}
\usepackage{marginnote}
\usepackage{menukeys}
\NewEnviron{command}[1]{%
\par
\reversemarginpar\marginnote{\texttt{\string#1}}
\BODY
\par
\textbf{Example:} % And here is #1 with #2, but literally typeset (e.g. literally \keys{Shift + F5})
\par
%#1#2 % <-- I'd like to typeset these two inputs properly (e.g. non-literal \keys{Shift + F5})
\par
}%
\begin{document}
\begin{command}{\keys}% {{Shift + F5}} % Example input does not work
This command allows you to add keyboard strokes. % here is the definition followed by an example on the next line.
\end{command}
\end{document}
Desired Output

My Thoughts
Maybe this is not even the right approach. I do not know how to go about dealing the commands with multiple arguments efficiently (e.g. created with the xparse package).




This command prints the \TeX\ logo.– Jonathan Komar Apr 22 '15 at 06:09\tl_set:Nnbusiness? I lost control of the code because I don't understand it. As it turns out, I don't want the commands to be in the margin. Normally I would just get rid of themarginnoteand use a minipage or something. Also, I find it confusing that the first example usesxparse, but the second one does not. Really great work! Thanks for the help. – Jonathan Komar Apr 22 '15 at 06:33texdoc interface3for more information. – egreg Apr 22 '15 at 06:46\tikz \node [fill=blue!15] {\l_macmad_argument_i_tl};\par. However, I was not able to do the same to the typeset/reread version\l_macmad_argument_tlfor some reason. Thanks for pointing me in the right direction! I am sitting here with a paper copy of thexparsedocumentation in front of me. I will check outinterface3– Jonathan Komar Apr 22 '15 at 06:47tl=token list and thatl= parameters whose value should only be set locally. Are those referring to what you have as\tland\l? I also see the_tlappended to the variable name. – Jonathan Komar Apr 22 '15 at 12:23_<type>, so_tl,_seq,_clistand so on. – egreg Apr 22 '15 at 13:01\l_macmad_argument_ii_tlin\tl_if_blank:VF \l_macmad_argument_ii_tl {\l_macmad_argument_ii_tl }in braces? – Jonathan Komar Apr 23 '15 at 06:21\l_macmad_argument_tlto contain the standard tokens of arg1 e.g.\frameboxThen you follow it with{}which I don't understand, then\l_macmad_argument_i_tl. The manual states that rescan takes "⟨tl var⟩ {⟨setup⟩} {⟨tokens⟩}". tl var=\l_macmad_argument_tl, setup={}, tokens=\l_macmad_argument_i_tl? Is that correct? Where is your setup? And if it is just{}, what does that mean? – Jonathan Komar Apr 23 '15 at 06:40\tl_set_rescan:Nnnrequires three arguments: the variable to set, optional assignments (in this case none) and the tokens to rescan. Here I use a variant\tl_set_rescan:NnVwhere the third argument is taken to be the value of a variable. – egreg Apr 23 '15 at 08:30