Background
I have seen beautiful manuals with commands and descriptions of what they do. I have a shared preamble (edited by multiple people and used for multiple documents) that has a multitude of custom commands created with
- \newcommand
- \DeclareRobustCommand
- \DeclareDocumentCommand (
xparsepackage) - \renewcommand
- etc.
and a multitude of environments
- \newenvironment
- \NewEnviron (
environpackage) - etc.
Recently, I asked the question: Is there a way to iterate over all defined colors without mentioning them again?
It turned out to be great! I was wondering whether I can do something similar with commands and their environments despite all of their complexities. All of my commands and environments have a three letter prefix, e.g. mbm (for "made by me").
Goal
I would use this to create a template list of left-aligned commands/environments, followed by an aesthetically-pleasing space followed by a description of that command or environment.
Example with Pseudocode
\documentclass{article}
\usepackage{fontspec}
\usepackage{listings}
\usepackage{tikz}
\usepackage{pgffor}
% Commands
\newcommand\mbmA{elephants}
\newcommand\mbmB[1]{#1}
\newif\ifcolormodules
\DeclareRobustCommand{\mbmmodule}[1]{%
\textbf{\textit{{\ifcolormodules\color{green}\fi #1}}}%
}%
\newcommand{\dq}[1]{\char"201C{}#1\char"201D{}} % Exception to mbm prefix rule
\newcommand{\sq}[1]{\char"2018{}#1\char"2019{}} % Exception to mbm prefix rule
% Environments
\lstnewenvironment{mbmlstcode}{\lstset{basicstyle=\ttfamily\small,columns=fullflexible,keepspaces=true,basewidth=0.5em}}{}
\NewEnviron{mbmerrors}{%
\BODY
}
\begin{document}
\section{Commands}
\foreach \definedcommand in {defined commands} % pseudo-code
\begin{tikzpicture}
\node [minimum width=3cm, minimum height=1cm,text=red] {\string\definedcommand}; % pseudo-code
\end{tikzpicture}
\section{Environments}
\foreach \definedenvironment in {defined environment} % pseudo-code
\begin{tikzpicture}
\node [minimum width=3cm, minimum height=1cm,text=orange] {\string\definedenvironment}; % pseudo-code
\end{tikzpicture}
\end{document}
doxpackage. – Samuel Albert Apr 10 '15 at 08:39grepand searching for patterns. The only way to do that would be to redefine each command to include a writeout to some list that could be printed later. It was not worth the effort...for color definitions, however, I did create such a command where I defined groups of colors called palettes (accent colors, main colors) whose list I could easily print. – Jonathan Komar Jan 25 '19 at 13:32\documentednewcommand{\command}{<Documentation for \command>}and similar commands for environments etc. and let these write in the aux-file such that you can print a list of commands just like a list of figures in the end? That is how I would have approached it. Or is there an inherent problem with this approach? – Dave Jan 25 '19 at 13:43\newcommand{.... For the reamining 10%-20%, I could imagine to have a command that allows to add an additional documentation entry manually. – Dave Jan 26 '19 at 11:10