Take the 2-minute tour ×
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.

I have to write a small demonstration of some features of my package. I was thinking about doing something like:

\documentclass{article}

\usepackage{listings}

\newcommand{\demo}[1]{%
    \fbox{
    \begin{minipage}{.5\linewidth}
    #1
    \end{minipage}}%
    \fbox{%
    \begin{minipage}{.5\linewidth}
    \begin{lstlisting}
    #1
    \end{lstlisting}
    \end{minipage}}
}

\begin{document}

\demo{\section{section}}

\end{document}

But this isn't working, because of listings can't be used inside commands. Any nice solution? (Would like to have a left right comparison between source and result)

And is there some way to enclose this so that nothing outside is affected?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can use and set the listings parameter in the usual way:

\documentclass{article}
\usepackage{showexpl}
\begin{document}

\begin{LTXexample}[width=0.5\linewidth]
\section{section}
\end{LTXexample}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

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.