![如果不使用 minipage,我们可以调整 LTXexample 的输入框和输出框的大小吗?](https://linux22.com/image/233324/%E5%A6%82%E6%9E%9C%E4%B8%8D%E4%BD%BF%E7%94%A8%20minipage%EF%BC%8C%E6%88%91%E4%BB%AC%E5%8F%AF%E4%BB%A5%E8%B0%83%E6%95%B4%20LTXexample%20%E7%9A%84%E8%BE%93%E5%85%A5%E6%A1%86%E5%92%8C%E8%BE%93%E5%87%BA%E6%A1%86%E7%9A%84%E5%A4%A7%E5%B0%8F%E5%90%97%EF%BC%9F.png)
\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]