1

This question already has an answer here:

What program can be used to output the definition of some macros or some environments provided by a particular package without having to read all the package file. A program that output only the needed definition.

example: how to check the definition of the TheSolution environment provided by the exam class

marked as duplicate by Circumscribe, Kurt, Sebastiano, TeXnician, Stefan Pinnow Nov 29 '18 at 20:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You can find it in the cls file. For example, here ctan.org/tex-archive/macros/latex/contrib/exam you find the class. Of course, if you have it in your machine, you can open it. – Sigur Nov 29 '18 at 19:03
  • 2
    \show\thesolution (to the terminal) or \meaning\thesolution (to the document) or (better) read the source file for the exam class – David Carlisle Nov 29 '18 at 19:04
  • \meaning does the job. Thank you all – Hafid Boukhoulda Nov 29 '18 at 19:16
  • You may want to use \texttt{\meaning<macro name>} then, because otherwise backslashes won't be typeset correctly (unless you're using fontenc). – Circumscribe Nov 29 '18 at 19:19
  • 1
    Both \show and \meaning can actually also be found in the answers to that question, as well as the fabulous texdef command line tool (which I highly recommend if you plan to do this often). – Circumscribe Nov 29 '18 at 19:26
3

The program you're thinking of is texdef, by Martin Sharrer. It can be found here, but should already be included with your TeX distribution.

To find out how a macro is defined, you can type latexdef <macro> or texdef -t latex <macro> (if the first one doesn't work), where <macro> is the name of the command you are interested in (without the initial \!).

If you want to know the definition when certain packages or classes are loaded, you can tell latexdef using -p [<options]<package> flag and -c [<options>]<class> respectively (article is used if no class is specified). To find out how TheSolution is defined if hyperref is loaded with the draft option (which actually makes no difference), you would for instance type

latexdef -c exam -p [draft]hyperref -E TheSolution

I added -E because TheSolution is an environment, so the definition of endTheSolution is also shown. If TheSolution had been a (dimension, skip, count, token sequence, …) register I would instead have ve added -v to see its value.

To figure out in which file a macro is defined you can -f, and you can then find out where this file is located using kpsewhich <filename>. If latexdef says that a macro is defined by LaTeX then it can probably be found in latex.ltx, in fontmath.ltx, or in one of the other files in the same directory.

There are many more options, which you can see by running texdef -h or by looking at the documentation.

Not the answer you're looking for? Browse other questions tagged or ask your own question.