1

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?

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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