1

I'm trying to show LaTeX commands using package showexpl. In the documentation of the package, it says that explpreset has a default value of . I think the sentence in documentation is not completed since it missed a full stop mark.

But when I add explpreset={} in defining style, it somehow ruins the style, what I first see the problem, is that the begin is not highlighted (end and most others are highlighted, though).

I'm curious how adding explpreset={} makes that difference. Does explpreset actually contain something in the beginning, or did I used it in a wrong way?

Also, what is special about the keyword begin that makes it not properly highllighted?

Here's MWE and the result:

\documentclass[12pt,a4paper]{article}
\usepackage{showexpl}

\lstdefinestyle{codestyle1}{
    basicstyle=\ttfamily\footnotesize,
    pos=b
}
\lstdefinestyle{codestyle2}{
    basicstyle=\ttfamily\footnotesize,
    pos=b,
    explpreset = {}
}
\begin{document}
\lstset{language=TeX,style=codestyle1}
\begin{LTXexample}
    \begin{center}
        Some text with code style1
    \end{center}
\end{LTXexample}

\begin{LTXexample}[explpreset={}]
    \begin{center}
        Some text with code style1 with empty explpreset
    \end{center}
\end{LTXexample}

\lstset{language=TeX,style=codestyle2}
\begin{LTXexample}
    \begin{center}
        Some text with code style2 with empty explpreset
    \end{center}
\end{LTXexample}

\end{document}

different styles when empty explpreset

1 Answer 1

0

The default settings for explpreset can be found in the source code of showexpl, near the end of the file showexpl.sty:

\lstset{explpreset={numbers=left,numberstyle=\tiny,numbersep=.3em,
  xleftmargin=1em,columns=flexible,language=[LaTeX]TEX},pos=l,width=-99pt,
  overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,rframe=single}

This explains the differences in the third block of your output: no line numbers and wider text (because of columns=flexible). The difference in highlighting is probably caused by the language setting TeX instead of [LaTeX]TeX, because begin is a LaTeX-specific keyword and the default dialect for the TeX language setting in listings is plain and not LaTeX. The end keyword on the other hand is part of the primitive set which is loaded by TeX.

It does not explain why the empty preset is ignored in the second example though. This may be a bug in processing the environment options - but I'm not entirely sure that this is the case.

You must log in to answer this question.

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