# How to get whole tex in the output document file with actual output?

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?

• You tagged with beamer but MWE uses article. Can you fix that? – percusse Apr 1 '13 at 14:35
• You can easily do this for small sections by putting a verbatim environment with a tex fragment on one minipage and some typeset text in a another minipage. but it would be hard to do this for a whole document allowing page breaks and keeping the typeset text aligned with the verbatim source. – David Carlisle Apr 1 '13 at 14:39
• Is there any alternative way to do successfully this aim ? Please tell me. – Soumitra Sen Apr 1 '13 at 14:41
• You can try to use package showexpl. – Mensch Apr 1 '13 at 14:45
• checkout the showexpl package ctan.org/tex-archive/macros/latex/contrib/showexpl. – susis strolch Apr 1 '13 at 14:46

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:

• 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 1 '13 at 15:47

\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.

• 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 1 '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 1 '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 1 '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 1 '13 at 16:03
• @DavidCarlise thank you very much. My problem is solved. – Soumitra Sen Apr 1 '13 at 16:16