[texhax] lstlisting frame from listings package too large

Daniel Greenhoe dgreenhoe at gmail.com
Wed Mar 20 13:53:16 CET 2013


Thank you! That works great.

Dan

On Wed, Mar 20, 2013 at 8:25 PM, Lars Madsen <daleif at imf.au.dk> wrote:
> use the various margin options provided by listings,  see the listings manual
>
> /Lars Madsen
> Institut for Matematik / Department of Mathematics
> Aarhus Universitet / Aarhus University
> Mere info: http://au.dk/daleif@imf / More information: http://au.dk/en/daleif@imf
>
>
> ________________________________________
> From: texhax [texhax-bounces at tug.org] on behalf of Daniel Greenhoe [dgreenhoe at gmail.com]
> Sent: 20 March 2013 13:12
> To: texhax at tug.org
> Subject: [texhax] lstlisting frame from listings package too large
>
> When I use the frame=single option in the lstlisting environment from
> the listings package, the frame produced extends outside the text area
> of the page, on both the left and right sides. One hack solution is to
> put the whole thing inside a minipage environment. However, is there a
> "better" solution? Here is a minimal example (see also attachments):
>
> \documentclass[oneside]{book}
> %
> \usepackage{geometry}
> \geometry{showframe}
> \usepackage{listings}
> \begin{document}%
>
> \begin{lstlisting}[frame=single]
>   x=1
>   x=2
>   x=3
> \end{lstlisting}
>
> \begin{minipage}{50mm}
> \begin{lstlisting}[frame=single]
>   x=1
>   x=2
>   x=3
> \end{lstlisting}
> \end{minipage}
> \end{document}%
>
> Many thanks in advance,
> Dan


More information about the texhax mailing list