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}

1 Answer 1

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]
6
  • @lockstep, thank you very much. It works. Excellent! :) Dec 8, 2010 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. Dec 8, 2010 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 8, 2010 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 8, 2010 at 16:17
  • So using explpreset is not a necessity, because I have tried without using it & still works. Thank you. Dec 8, 2010 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .