2

alt text

\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}
Display Name
  • 46,933

1 Answers1

5

The key width is only responsible for the formatted text, not the source code. To change the width of the typeset source code, modify your second LTXexample (without minipage) as follows:

\begin{LTXexample}[explpreset={linewidth=0.5\linewidth},width=0.5\linewidth,pos=b]
lockstep
  • 250,273
  • @lockstep, thank you very much. It works. Excellent! :) – Display Name Dec 08 '10 at 16:00
  • why do you enclose linewidth=0.5\linewidth by explpreset? without doing that, it still works. I don't know the purpose. – Display Name Dec 08 '10 at 16:07
  • 1
    It might be worth doing a \newcommand\mywidth{0.5\linewidth} or soemthing, so that you can change both widths at once... – Seamus Dec 08 '10 at 16:12
  • 1
    @xport: I followed p. 2 of the showexpl documentation and p. 33 of the listings documentation. Note: What follows explpreset= is a key-value-list of its own, possibly with several entries. – lockstep Dec 08 '10 at 16:17
  • So using explpreset is not a necessity, because I have tried without using it & still works. Thank you. – Display Name Dec 08 '10 at 16:29
  • @lockstep, I did an experiment. Here the result: explpreset={} can contain options from listings and/or showexpl. It is worth using explpreset whenever we use both lstlisting and LTXexample in the document. By setting some options in explpreset, these settings will be applied to LTXexample only (without affecting lstlising). Options declared in lstset will be applied to both LTXexample and lstlisting, unless they are overriden using their optional arguments. Thank you. – Display Name Dec 09 '10 at 10:22