\documentclass[dvipsnames]{article}
\usepackage{xcolor}
\usepackage[margin=50mm]{geometry}
\usepackage{showexpl}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\SX@codeInput}{xleftmargin=0pt,xrightmargin=0pt}{}
{\typeout{***Successfully patched \protect\SX@codeInput***}}
{\typeout{***ERROR! Failed to patch \protect\SX@codeInput***}}
\makeatother
\lstset{%
literate={ï}{}0
{»}{}0
{¿}{}0,
breaklines=true,
breakindent=0pt,
basicstyle=\ttfamily\scriptsize,
keywordstyle=\color{blue}\sffamily\bfseries,
commentstyle=\color{Green}\itshape,
stringstyle=\rmfamily,
showstringspaces=false,
backgroundcolor=\color{Yellow!30},
frame=single,
framerule=0.4pt,
rulecolor=\color{red},
framesep=3pt,
xleftmargin=3.4pt,
xrightmargin=3.4pt,
tabsize=2,%
explpreset={pos=b,language={[LaTeX]TeX}}%
}
\begin{document}
\section{with minipage}
\noindent%
\begin{minipage}{0.5\linewidth}
\begin{LTXexample}[pos=b]
\begin{enumerate}
\item $\displaystyle \lim_{x\to 8}\frac{1}{(x-8)^2}=+\;\rotatebox{90}{$8$}$
\item $\displaystyle \lim_{x\to 7}\frac{1}{(x-7)^2}=+\;\rotatebox{90}{$7$}$
\item $\displaystyle \lim_{x\to 6}\frac{1}{(x-6)^2}=+\;\rotatebox{90}{$6$}$
\end{enumerate}
\end{LTXexample}
\end{minipage}
\section{without minipage}
\noindent%
\begin{LTXexample}[width=0.5\linewidth,pos=b]
\begin{enumerate}
\item $\displaystyle \lim_{x\to 8}\frac{1}{(x-8)^2}=+\;\rotatebox{90}{$8$}$
\item $\displaystyle \lim_{x\to 7}\frac{1}{(x-7)^2}=+\;\rotatebox{90}{$7$}$
\item $\displaystyle \lim_{x\to 6}\frac{1}{(x-6)^2}=+\;\rotatebox{90}{$6$}$
\end{enumerate}
\end{LTXexample}
\end{document}
答案1
该键width
仅负责格式化文本,而不负责源代码。要更改排版源代码的宽度,请LTXexample
按如下方式修改第二个(不带 minipage):
\begin{LTXexample}[explpreset={linewidth=0.5\linewidth},width=0.5\linewidth,pos=b]