[texhax] lstlisting frame from listings package too large

Daniel Greenhoe dgreenhoe at gmail.com
Wed Mar 20 13:12:17 CET 2013


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: listings.tex
Type: application/x-tex
Size: 529 bytes
Desc: not available
URL: <http://tug.org/pipermail/texhax/attachments/20130320/2fc61417/attachment.tex>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: listings.pdf
Type: application/pdf
Size: 2327 bytes
Desc: not available
URL: <http://tug.org/pipermail/texhax/attachments/20130320/2fc61417/attachment.pdf>


More information about the texhax mailing list