# 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}