Hi *
I often use the verbatim environment, and one of the coolest things, is that this env is able
to correctly put stuff across pages.
Recently, I startet working in a book (twosided) with margins.
The result I'm getting on verbatim stuff that crosses pages (and I want this to be non-float),
is:
- odd pages: outer alignement is ok
- even pages: outer alignement is not ok (does not use the margin space on the left)
How can I instruct LaTeX to correctly align the outer margin in even pages?
I know that there are tricks to do this with floats (figures and tables), by I want that this to
be non-float.
Cheers,
Nuno
P.S. I put a similar question wrongly in another forum (General:Latex Community), and till now
I did not received any reply. Thus, I put here a simpler version of my question. It was about
the listings package, which also as the ability to cross pages.
General ⇒ verbatim - body + margin
Re: verbatim - body + margin
Ups
Shoub be:
- odd pages: inner alignement is ok and verbatim uses the right margin if it needs
- even pages: outer alignement is not ok (does not use the margin space on the left)
Thanks
N.
Shoub be:
- odd pages: inner alignement is ok and verbatim uses the right margin if it needs
- even pages: outer alignement is not ok (does not use the margin space on the left)
Thanks
N.
verbatim - body + margin
In this thread you can find (part of) the answer.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
verbatim - body + margin
Hi * & gmedina
Thanks for the reply.
Since I posted the question, I did try to solve the problem, and playing with \leftmargin and \rightmargin seems to be the path to follow.
Going to share some of my findings to help others. Here is a minimal example:
The package "chngpage" does the job of checking if the STUFF being printed is on a odd or even
page, and it takes care of changing the alignment margins of stuff inside the for even and odd pages. In this case (book class) usually one wants STUFF to be expanded to outside margins, that's why the use of . Check chngpage.sty for more info.
This only works fine if STUFF is not printed across pages. If it's the case,
then the best I found out was to break the STUFF into pieces.
I've given here an example using the listings package, did not tryed with a verbatim
environment, since the first goal was indeed to play with this listings package
(see post http://latex-community.org/viewtopic.ph ... c983f1dc35).
Many thanks.
Nuno
Thanks for the reply.
Since I posted the question, I did try to solve the problem, and playing with \leftmargin and \rightmargin seems to be the path to follow.
Going to share some of my findings to help others. Here is a minimal example:
Code: Select all
\documentclass{book}
% change the page layout in the middle of a document, and robustly
% check for typesetting on odd or even pages
\usepackage[strict]{chngpage}
% layout settings
\usepackage[a4paper,twoside,marginparwidth=60pt,marginparsep=10pt,
includeheadfoot]{geometry}
% source code typesetting
\usepackage{listings}
% Margin width
\newlength{\marginwidth}
\setlength{\marginwidth}{\marginparwidth}
\addtolength{\marginwidth}{\marginparsep}
\begin{document}
Here is some source code filling the body $+$ margin \ldots
\begin{adjustwidth}[]{}{-\marginwidth}
\lstinputlisting[firstnumber=1,linerange=1-13]{some.file}
\end{adjustwidth}
\end{document}
page, and it takes care of changing the alignment margins of stuff inside the
Code: Select all
\begin{adjustwidth}[]{}{-\marginwidth} STUFF \end{adjustwidth}
Code: Select all
\begin{adjustwidth}[]{}{-\marginwidth}
This only works fine if STUFF is not printed across pages. If it's the case,
then the best I found out was to break the STUFF into pieces.
I've given here an example using the listings package, did not tryed with a verbatim
environment, since the first goal was indeed to play with this listings package
(see post http://latex-community.org/viewtopic.ph ... c983f1dc35).
Many thanks.
Nuno