Skip to content

Instantly share code, notes, and snippets.

@kbauer
Created July 15, 2015 15:52
Show Gist options
  • Save kbauer/d8bad4d44603465ffd5d to your computer and use it in GitHub Desktop.
Save kbauer/d8bad4d44603465ffd5d to your computer and use it in GitHub Desktop.
For debugging/learning LaTeX internals it is useful to dump the definition of commands. Reading the output of `\show` from the console however is inconvenient. The command `\meaning` is useful here (as it prints the definition to the document) but limited. `\mymeaning` is a wrapper, where you specifiy the name of a macro rather than the `\macro`…
% \mymeaning{command} -> Definition of \command
\makeatletter
\newcommand{\mymeaning}[1]{
\begingroup%
\setlength{\parindent}{0em}
\setlength{\hangindent}{1em}
\edef\@tmp{\ifmmode\noexpand\mathtt\else\noexpand\texttt\fi}
\@tmp{%
\expandafter\string\csname #1\endcsname->%
\expandafter\meaning\csname #1\endcsname;%
}%
\@ifundefined{#1\space}{}{
\par
\mymeaning{#1\space}
}
\endgroup%
\par%
}
\makeatother
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment