考虑以下 LaTeX 文档
\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}
它给出以下输出
(a)这是第一行。
(b)这是第二行。
但是,我想获得以下输出
\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}
也就是说,左侧的列将包含整个文本,而右侧的列将包含 TeX 代码的原始输出。有什么办法可以做到这一点吗?
答案1
这是您的 MWE 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}
请查看该包中提供的示例。
你应该得到:
答案2
\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}
ex1.tex
你的例子在哪里?