Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{article}
- \usepackage[T1]{fontenc} %% <- necessary for _ to be displayed correctly
- \usepackage{etoolbox} %% <- for \csuse, \csdef, \ifcsdef and \forcsvlist
- %% Define/retrieve a new keyword:
- \newcommand\setkeyword[3]{%
- \csdef{keyw@descr@#1}{#2}%
- \csdef{keyw@value@#1}{#3}%
- }
- \newcommand*\getkeyword[2]{%
- \ifcsdef{keyw@#2@#1}{% %% <- if the key is defined...
- \csuse{keyw@#2@#1}% %% <- return the description
- }{% %% <- otherwise...
- ??% %% <- let's just print ??
- }%
- }
- \newcommand*\getdescription[1]{\getkeyword{#1}{descr}}
- \newcommand*\getvalue[1]{\getkeyword{#1}{value}}
- %% Display a table describing a list of keywords:
- \newcommand*\keywordtable[1]{%
- \begin{center}
- \begin{tabular}{lrl}
- \textbf{Parameter} & \textbf{Value} & \textbf{Description} \\
- \forcsvlist{\tableentry}{#1} %% <- apply \tableentry to each value in #1
- \end{tabular}
- \end{center}%
- }
- \newcommand*\tableentry[1]{%
- \formattableentry{\detokenize{#1}}{\getvalue{#1}}{\getdescription{#1}}%
- }
- \newcommand\formattableentry[3]{ #1 & #2 & #3 \\ }
- % %% Declaration of keywords:
- \setkeyword{runtype}{A parameter}{1}
- \setkeyword{param_1}{Another parameter}{0}
- \setkeyword{param_2}{A third parameter}{42}
- \begin{document}
- \section{Runtype 1 description}
- \keywordtable{runtype,param_1}
- \section{Runtype 2 description}
- \keywordtable{runtype,param_2}
- \end{document}
Add Comment
Please, Sign In to add comment