A TikZ path statement, such as

\path[draw] (0,0) -- (1,0);

is not generally rendered linearly. The TikZ "engine" breaks it apart, shifts its parts around, and finally renders them in some order that may bear little resemblance to their textual organization in the TeX manuscript.

How can I view the final, definitive, fixed-order sequence of basic-layer and/or system-layer commands that is emitted by the TikZ engine? If it isn't possible to view this sequence on a per-path basis, perhaps it is possible to view the sequence generated by the entire TikZ picture?

I'm also willing to "compromise" on the list of \specials that the picture translates to, rather than the list of basic-layer/system-layer commands.

Alternatively, is it possible to apply a \showbox to a TikZ picture? Or if I explicitly wrap the TikZ picture in a TeX box and then \showbox it, will it list the internal order of execution of the TikZ picture?

As a last resort, how can I view the list of \specials that the entire TeX manuscript translates to?


1 Answer 1


The usual approach here with TeX code seems to apply: use \tracingall, \show, \showbox and \showoutput. For example, if we take the suggested input fragment and make it into a document

\path[draw] (0,0) -- (1,0);

we can insert \showoutput and then examine the .log to find (with pdfTeX) that the image boils down to

.......\pdfliteral{q }
.......\glue 0.0
.......\pdfliteral{0.0 0.0 m }
.......\pdfliteral{28.3468 0.0 l }
.......\pdfliteral{S }
.......\pdfliteral{Q }
.......\glue 0.0 plus 1.0fil minus 1.0fil
......\pdfliteral{n }
......\pdfliteral{Q }
......\glue 0.0 plus 1.0fil minus 1.0fil

i.e. some save/restore material with the real 'meat' being setting the line width, moving to a point and drawing a line. That is backed up by \tracingall: a quite search for \pgf@sys in the result yield for example

\pgfsyssoftpath@movetotoken #1#2->\pgfsys@moveto {#1}{#2}

\pgfsys@moveto #1#2->\pgf@sys@bp {#1}\pgf@sys@bp {#2}\pgfsysprotocol@literal {m


\pgfsyssoftpath@linetotoken #1#2->\pgfsys@lineto {#1}{#2}

\pgfsys@lineto #1#2->\pgf@sys@bp {#1}\pgf@sys@bp {#2}\pgfsysprotocol@literal {l

which I think is all relatively predictable: reading over the system layer of pgf it's clear that it abstracts to such basic concepts.

For this kind of tracing, I'd recommend using \tracingall inside the picture (reduces teh number of lines), probably just before the line of interest. The \showoutput command works on a per-page basis so anywhere before \end{document} in a single one-page file is fine.

  • Thanks. Where in the manuscript would I insert the \showoutput/\traicingall? Does it matter?
    – Evan Aad
    Commented Aug 6, 2017 at 7:19
  • Thanks for the edit. Is there a way to turn the tracing off, so I can capture just the part I'm interested in?
    – Evan Aad
    Commented Aug 6, 2017 at 9:22
  • And another question: is there a way for me to inject comments into the tracing stream at points of my choosing, so that I can have an easier time navigating the trace output and mapping trace segments to the source code?
    – Evan Aad
    Commented Aug 6, 2017 at 9:37
  • 1
    @EvanAad Those are general TeX debugging questions (I think covered before). Briefly: \tracingall respects TeX groups but can also be cancelled using \tracingnone. There is also the trace package which offers \traceon/\traceoff. TeX's a macro language, so if you want to add tokens to a macro you can patch them in (etoolbox, etc. or simply redefine): I favour \MARK for this (it's undefined so interrupts the run).
    – Joseph Wright
    Commented Aug 6, 2017 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .