9

Consider the following LaTeX document

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

\begin{enumerate}[(a)]

\item Here is the 1st line.
\item Here is the 2nd line.

\end{enumerate}

\end{document}

It gives the following output

(a) Here is the 1st line.
(b) Here is the 2nd line.

However, I'd like to get the following output

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

\begin{enumerate}[(a)]

\item Here is the 1st line.                   (a)  Here is the 1st line.
\item Here is the 2nd line.                   (b) Here is the 2nd line            

\end{enumerate}

\end{document}

That is the left side of the columns will contain the whole text and the right side of the columns will contain the original output of the TeX code. Is there any way to do this?

egreg
  • 1,121,712
Soumitra Sen
  • 2,995

2 Answers2

7

Here is your MWE with showexpl:

\documentclass{article}
\usepackage{enumerate}
\usepackage[final]{showexpl}

\begin{document}

\begin{LTXexample}
\begin{enumerate}[(a)]
\item Here is the 1st line.
\item Here is the 2nd line.
\end{enumerate}
\end{LTXexample}

Another possibility in Listing~\ref{ex:test}:

\begin{LTXexample}[pos=r,rframe={},caption={Test},label=ex:test]
\begin{enumerate}[(a)]
\item Here is the 1st line.
\item Here is the 2nd line.
\end{enumerate}
\end{LTXexample}

Another possibility is:

\begin{LTXexample}[pos=r,rframe=single,numbers=none,basicstyle=\ttfamily\small,]
\begin{enumerate}[(a)]
\item Here is the 1st line.
\item Here is the 2nd line.
\end{enumerate}
\end{LTXexample}

Original environment in document:
\begin{enumerate}[(a)]
\item Here is the 1st line.
\item Here is the 2nd line.
\end{enumerate}

\end{document}

Please have a look into the examples provided with that package.

You should get: enter image description here

Mensch
  • 65,388
  • this is working well but I want to get the text within the box in the right hand column. Is it possible.Besides, I do not want serial number appeared in the output. Is it possible ? Thank you. – Soumitra Sen Apr 01 '13 at 15:47
4

enter image description here

\documentclass{article}
\usepackage{verbatim}
\usepackage{enumerate}

\begin{document}

\noindent
\begin{minipage}{.42\textwidth}
\verbatiminput{ex1.tex}
\end{minipage}
\hfill
\vrule
\hfill
\begin{minipage}{.42\textwidth}
\def\documentclass#1{}
\def\usepackage#1{}
\renewenvironment{document}{}{}
\input{ex1.tex}
\end{minipage}

\end{document}

where ex1.tex is your example.

David Carlisle
  • 757,742
  • your given example shows the following errors. ./example.tex:9:Tex capacity exceeded,sorry [text input levels=15]\verbatiminput{example.tex} I don't know what is this. Please explain. – Soumitra Sen Apr 01 '13 at 15:37
  • You input my document into itself and got into an infinite loop, ex1.tex is supposed to be your example from the question. – David Carlisle Apr 01 '13 at 15:42
  • I have changed my text document name to ex1.tex. But the the occured again.i.e ./ex1.tex:9:Tex capacity exceeded,sorry[text input levels=15]\verbatiminput{ex1.tex} – Soumitra Sen Apr 01 '13 at 15:53
  • @SoumitraSen I do not see how you could get that unless you have defined the document to input itself. You need two documents the one in my answer and the one in the question. If you process the document in this answer you will then get the output shown. – David Carlisle Apr 01 '13 at 16:03
  • @DavidCarlise thank you very much. My problem is solved. – Soumitra Sen Apr 01 '13 at 16:16