How to change the margin of code's frame of showexpl.sty when numbers=none?
- by suugaku
Hi all,
I want to align the code's frame with the formated text's frame.
If the numbers=left,the mission is accomplished by configuring xleftmargin, xrightmargin, framesep, and numbersep.
However, when I set numbers=none, I cannot accomplish my mission by configuring those properties.
Regardless of the values set to those properties, the code's frame remains unchanged and expands beyond the \textwidth.
Please see my code snippet below.
Thank you in advance.
\documentclass[a4paper,11pt,twoside,final,dvips]{book}
\usepackage{xcolor}
\usepackage{showexpl}
\lstset{%
breaklines=true,
breakindent=0pt,
basicstyle=\color{magenta}\ttfamily\tiny,
keywordstyle=\color{blue}\sffamily\bfseries,
identifierstyle=\color{black},
commentstyle=\color{cyan}\itshape,
stringstyle=\rmfamily,
showstringspaces=false,
tabsize=2,
%========== FRAME ==========
frame=single,
framerule=0.4pt,
rulecolor=\color{red},
framesep=3pt,
%========== MARGIN ==========
xleftmargin=3.4pt,
xrightmargin=3.4pt,
%========== NUMBER ==========
numbers=left,
numberstyle=\color{red}\tiny,
numbersep=6.4pt,
explpreset={language={[LaTeX]TeX},pos=b}%
}
\usepackage{lipsum}
\usepackage{printlen}
%------------------------- MARKER ------------------------
\newlength{\halftextwidth}
\setlength{\halftextwidth}{\textwidth*\real{0.5}}
\newcommand*{\MARKER}%
{%
\uselengthunit{cm}
\par\noindent\strut\vrule%
\hrulefill~%
{\color{red}\scriptsize half text area: \printlength{\halftextwidth}}%
~\hrulefill\vrule%
\hrulefill~%
{\color{red}\scriptsize half text area: \printlength{\halftextwidth}}%
~\hrulefill\vrule%
\marginpar%
{%
\strut\vrule\hrulefill~%
{\color{red}\scriptsize margin area: \rndprintlength{\marginparwidth}}%
~\hrulefill\vrule%
}%
\par%
}%
\begin{document}
\chapter{I love \LaTeXe, but $\cdots$}
\section{With numbers=left}
\vfill
\MARKER
\begin{LTXexample}
\lipsum[1-1]
\end{LTXexample}
\MARKER
\vfill
\pagebreak
\section{With numbers=none}
\vfill
\MARKER
% Any values that are assigned to xleftmargin or xrightmargin
% have no effect on the margin of the code's frame.
\begin{LTXexample}[numbers=none,xleftmargin=10.4pt,xrightmargin=10.4pt]
\lipsum[1-1]
\end{LTXexample}
\MARKER
\vfill
\end{document}