TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
I have removed the "thanks", we usually don't write below our questions (although I am always tempted to do so). – topskip Mar 24 '12 at 15:21
Similar issues arise when tikzpicture environments are nested: The inner environment inherits all PGF keys from the outer one. Apparently, no one here seems to know how to work around this, too -- given that the question even had a bounty assigned to it: tex.stackexchange.com/q/47377/8057 – krlmlr Mar 25 '12 at 14:02

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.

share|improve this answer

I would use the following strategy:

  1. Make a "generic document wrapper" containing preamble and such.
  2. Put all examples into separate tex files.
  3. Format each example separately by combining the generic wrapper and the example text itself.
  4. Include the formatted result as a pdf file.

It's up to your imagination how to automate parts or all of this process. The preview package comes to mind, make files or whatever. You can keep the examples together in your source document using the filecontents environment.

For getting a tightly clipped includable version of an example document, you can use pdfcrop (or again preview).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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