3

How can I see the definition of the macro? I come from the programming background and it would be nice to see how the macro is defined. Perhaps even better if there would be something similar to Lisp's macroexpand and macroexpand-1 commands. Is there a way to stop processing and leave a REPL for tex where I can run commands or get access to the current state of the processed document.

I looked at \the, \show and \meaning and I think \meaning is kind of close to what I was looking for. However it's not really showing me the macro definition in full. As for latexdef doesn't it just do text search in TEXMF directory ? This may not really work for dynamically defined macros and macros from modules outside of TEXMF.

I am asking this in the context of ConTeXt so perhaps the fact that it uses LuaTeX could be helpful for me.

  • 2
    Welcome to TeX.SE! Are you looking for \show? Or latexdef, which has to be typed on the terminal? – marmot Dec 19 '18 at 15:32
  • moved my comment to a question. – EvgeniySharapov Dec 19 '18 at 15:50
  • I'm not sure why you say that \show isn't showing the meaning of a macro: that's exactly what it's doing – Joseph Wright Dec 19 '18 at 17:08
  • If you want the 'full trace', \tracingall is your friend (I hope you like long logs!) – Joseph Wright Dec 19 '18 at 17:09
  • I didn't get much luck with \show. Simple file ``` \starttext \show\strut \stoptext ``` results in an error. \tracingall though is a good one to explore – EvgeniySharapov Dec 19 '18 at 17:26
4

You can run

mtxrun --silent --script context \
  --extra=meaning --once --noconsole --nostatistics \
  <command>

on the console. For instance

mtxrun --silent --script context \
  --extra=meaning --once --noconsole --nostatistics \
  setuplayout

Outputs:

meaning         > setuplayout

\protected macro:->\dodoubleempty \setup_layout
  • Oh, this one is fantastic ! I wonder if there's a way to also run some kind of REPL ? – EvgeniySharapov Dec 19 '18 at 17:21
  • @EvgeniySharapov You can run TeX interactively, but I never use that. For debugging ConTeXt has a lot to offer using \enabletrackers[…] or context --trackers=…. List all trackers with: context --showtrackers But if that's useful depends on what you're actually after. For definitions I usually just grep the source. – Marco Dec 19 '18 at 17:48
  • How would I run context interactively ? I looked at [contextgarden.net/Console_Mode]() but it doesn't work. It just spits out .tmp file with TeX inside and quits. – EvgeniySharapov Dec 19 '18 at 17:59
  • 3
    @EvgeniySharapov You can use context --pipe to start an interactive session. – Marco Dec 19 '18 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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