[Tex/LaTex] Show output of a full LaTeX document


A couple of days ago, I found showexpl, it is wonderful and works very well. But there is one thing missing that it doesn't let me do and it is to only show the output/result of some commands. For little commands, there are no problems, a minipage inside an fbox works well, but for displaying titles and sections without affecting the number count in the document I have no idea how to do (except by embedded an image of the rendered document, which isn't that great of an idea).

For an example of what I am saying, I saw this a while ago while reading this tutorial (on page 4 there is an example of a document): https://dataninja.files.wordpress.com/2008/09/texpert2.pdf

Best Answer

You will need to manually rewind the counters after they have been executed, as well as write quite a few macros to save state and restore state. I use a similar package called tcolorbox, here is a MWE illustrating the technique for keeping section numbers consistent.

enter image description here

\title{My Title}
\advance\c@section by -2

I am not aware of any package that can be used to run full minimal examples though. One way is to save them on disc using a verbatimwrite, execute them via enabling write18 and then import the pdf. Perhaps FMi can describe what they used when they wrote the LaTeX Companion.

Quick implementation hack to display MWE.