TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

showexpl package is intended to show (La)TeX, TikZ, PSTricks codes and their coressponding rendered outputs at the same time (either horizontally or vertically).

Note that it cannot be used to show C# or C++ or Mathematica or others and their outputs because these language use different compilers or render engines.

showexpl is derived from listings package so options defined in listings can be used in showexpl either by using \lstset{...} or \lstset{explpreset={...}} as follows.



   explpreset=% I add the missing = here!

I have read the showexpl package and the source code of its example document, but I am still confused what explpreset is actually for--because \lstset{} already exists and it can do what explpreset wants to do. The following is a short description of explpreset:

enter image description here

Do you have idea, what is explpreset is actually for?

share|improve this question
Thanks for those who answered this question. All of them have been given a plus one for their good answers. However I have only one green check mark and it was given to Martin for the technical details. :-) – xport Aug 7 '11 at 22:59
up vote 7 down vote accepted

The explpreset key simply stores its value into the \SX@explpreset macro which is later used inside a local \lstset. This allows to define listings settings only for showexpl listings but not for other ones.

The exact usage is as follows:

showexpl.dtx, 2007/02/03 v0.3h, line 251:


by default it is empty: (line 285)


It is then used by the LTXexample environment to set local \lstset settings: (starting from line 423)

%    \end{macrocode}
% For "codefile=..."/"graphic=..." if \cmd{\theltxexample} or 
% \cmd{\thelstlisting} is part of the filename.
%    \begin{macrocode}
    \advance\c@ltxexample\@ne \advance\c@lstlisting\@ne 

This environment writes the code into an external file and calls the \SX@put@code@result macro afterwards to typeset it. This macro again uses the same settings: (line 457-)

share|improve this answer

Using the explpreset key inside lstset, you can customize only the attributes for the LTXexampe environments, and this gives you the possibility to define different attributes for the lstlisting environment. A simple example illustrating this:







enter image description here

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.