LaTeX book class: Twosided document with wrong margins - latex

I am trying to write my thesis in latex... Cannot get the layout straight though :?
I'm using the following document class:
\documentclass[11pt,a4paper,twoside,openright]{book}
My problem is: on the odd numbered pages there is a big margin right, and a small margin left - it should be the other way round... (for binding & stuff)
I am a little puzzled by this -- am I just to stupid to see the obvious? The odd page numbers appear on the 'right' page of a bound document, so there needs to be a larger gutter margin on the left for binding -- and vice versa. Right?
Why does LaTeX not behave like this?
Here is the full code to produce a small Tex file that shows my problem:
\documentclass[11pt,a4paper,twoside,openright]{book}
\begin{document}
\chapter{blah}
Lorem ipsum ius et accumsan tractatos, aliquip deterruisset cu usu. Ea soleat eirmod nostrud eum, est ceteros similique ad, at mea tempor petentium. At decore neglegentur quo, ea ius doming dictas facilis, duo ut porro nostrum suavitate.
\end{document}
Edit:
I know about a lot of ways to manually specify the page margins, like
\setlength{\oddsidemargin}{53pt}
or ...
\usepackage[lmargin=1cm,rmargin=2.5cm,tmargin=2.5cm,bmargin=2.5cm]{geometry}
I just wanted to use the default settings and don't understand why they do not behave as expected.

I had the same problem. Anyhow, here the "simple" solution (put it in your preamble):
\let\tmp\oddsidemargin
\let\oddsidemargin\evensidemargin
\let\evensidemargin\tmp
\reversemarginpar
Cheers,
Chris
Edit: Contrary to the previous solutions, the provided code does not change the style of the document :)

No, that's right. The odd pages should have a bigger margin. If you take a twosided book, you have 3 margings: On the left, in the middle, on the right. Every margin should be the same size. The one in the middle is build by two margins from each side. So it has to be smaller.
If you want to add a bindingoffset, you need to use the package geometry:
\usepackage{geometry}
\geometry{bindingoffset=1cm}
or use another class, like the KOMA-classes:
\documentclass[11pt,a4paper,twoside,openright,BCOR=1cm]{scrbook}

The extra space is for the margin notes. In general, to see what's going on with your layout, you can put \usepackage{layout} in your preamble, and then stick \layout in your document to get a diagram and listing of geometry settings.
In your case, as I say, what's going in is the extra space for margin notes. If you don't want it, use \setlength{\marginparwidth}{0pt}.

If you have the time and inclination to learn more about this, and many other things about page layout and document design in general, I believe that studying the memoir package will give you an excellent return on your investment.
In particular, memdesign.pdf gives the underlying principles a thorough going-over, and memman.pdf is a comprehensive (though large!) reference.

In the case of the memoir class.
The margins are correct. There is more space to the right of the odd pages because of margin notes. As #etaoin pointed out, you can see the page layout with \usepackage{layout} and putting \layout within the document environment.
I don't use margin notes, therefore my solution is to reduce the \marginparwidth to 0 or set it to a small value.
You can do that directly by setting the length
\setlength{\marginparwidth}{0pt}
or using the command \setmarginnotes described in the documentation memman.pdf.
\setmarginnotes{0pt}{0pt}{0pt}
However, that didn't worked out for me immediately because the text width remained the same.
My final solution is to set a desired width to the margin note, then whatever width you gained you should add it to the text width. On the odd pages this works fine because the text expands to the right. However, on the even pages the text grows to the right but your free space is to the left.
You have to correct this by decreasing the even side margin as well.
Here's the complete solution:
% the new margin note width will be a fraction of the old one
\newlength{\notewidth}
\setlength{\notewidth}{0.2\marginparwidth}
% deltanotewidth is the space that we gain
\newlength{\deltanotewidth}
\setlength{\deltanotewidth}{\marginparwidth}
\addtolength{\deltanotewidth}{-\notewidth}
% update the note width
\setlength{\marginparwidth}{\notewidth}
% the text width grows
\addtolength{\textwidth}{\deltanotewidth}
% the even side margin reduces to fit the bigger text
\addtolength{\evensidemargin}{-\deltanotewidth}

Related

LaTeX - Automatically scale down an area so that it will be inside a page if it's too big?

I'm making a document in LaTeX. It includes a set of images in a row. A small percentage are quite wide and will stretch and push off the page. If I shrink all the image sequences then most of them will look too small. However it's not easy to figure out what sets are going to be too large. I'd like some automatic way to resize these sets.
Is there anyway to surround something with a command which will shrink it enough so that it fits within the width of the page? If it's already narrower than the page, then no shrinking is necessary?
you can do something like
\includegraphics[width=\textwidth]{figure}
or
\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
You may try the following macro:
\maxsizebox{〈width〉}{〈height〉}{〈content〉}
It only resizes the content if its natural size is larger than the given 〈width〉 or 〈height〉, but does not change the aspect ratio.
It is part of the adjustbox package. So you need to append to the preamble of your document:
\usepackage{adjustbox}
You can further read about it here.
The best way to scale down a big figure is this
\begin{figure}[!ht] \centering
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{"path to your figure"}
\caption{"your caption"}
\label{"your label"}
\end{figure}

dealing with large figures in Latex

I have a large figure that appears at the end of my document rather than in the section that I want to be in. Even \begin{figure}[h] doesn't help. Without scaling it down, how can I put it at the end of the section I want it in?
Using the afterpage package can be a good solution. However, using the option here you are trying to tell LaTeX where you want to put the image. Instead, you need to tell LaTeX where the image is good to be put:
use \begin{figure}[tb] for figures that fit well in a page with text (say, half of the text height for the figure and the other half for the text)
use \begin{figure}[p] for floats large enough to require a dedicated page.
Setting a proper option increase your chances to have the image almost where you want, having at the same time a good page layout.
If the figure is still too far from the page where it should be placed, you can set some "barriers" for floats positioning with the packages placeins or afterpage (already mentioned).
Here is a small tutorial for float placement. The thing you want to do is put an \afterpage{\clearpage} command at the end of the section. This will create an additional page after the current one and place the floats that are left in the queque there. If the float still doesn't get placed, you have to resize it. If you really don't want to resize it and it should fit on the page, then you could try changing the margins and text area temporarily (i.e. just for that one page) and see if that lets the float get placed.
i forget if it's the float or array package that provides this, but,
\begin{figure}[H]
...
\end{figure}
The upper case H will put the figure exactly where it is in your code.

LaTeX: typesetting chapter and section number in margin

I'm trying to typeset something in LaTeX and I would like to know if I'm doing it right. The basic idea is that section number hangs in the left margin. The number takes the height of the header+2 lines for a chapter heading, +1 line for section heading, and has the same height as the header for subsections, and is aligned to the top of the heading. See the following image to get an idea of what I'm talking about:
http://img62.imageshack.us/img62/8404/bladld.png
My approach is using titlesec and doing something like this:
\titleformat{\chapter}%
{\Huge\bfseries\sffamily}% format
{\vbox to 16pt{\llap{% label
\fontsize{3em}{0}\selectfont{\thechapter}%
\hskip 9pt%
}}}%
{0pt}% horizontal sep
{}% before
\titlespacing*{\chapter}%
{0pt}% left
{-2em}% before
{0pt}% after
But this solution has some hacks that I would rather avoid. The \vbox height for instance, is found by trial and error. Visually, it looks almost right...
Try using the memoir document class. That has a ton of options for doing exactly this kind of thing, and it's much neater...
There's a hangnum style and for sections, there's a \hangsecnum option, but that only puts the number in the margin: it doesn't make it bigger. Memoir is also fabulously documented. So I expect all everything you need will be there. The code for hangnum is on p.88 of the fantastic memoir manual. So from there and from later examples you should get all the pointers you need to get what you want...

How do I prevent LaTeX from padding spaces between paragraphs so that next section begins at top of next page?

I have a two-column paper where space restrictions are very tight.
I just looked at my last version of the manuscript and saw that the upper half contains a figure (as expected), but in the lower half there is a lot of vertical space between paragraphs (enough to squeeze 10 more lines), and that LaTeX probably added it so that in the beginning of the next page a new numbered section will begin at the top of the page.
I know there's a way to adjust this so LaTeX doesn't try so hard, but I'm not sure how. any help? Thanks!
The parameter that controls inter-paragraph spacing is called \parskip(See Paragraph Spacing ). You set it (with "rubber" values) using something like:
\setlength{\parskip}{1cm plus4mm minus3mm}
The defualt value of \parskip is class dependent. The "plus" and "minus" parts tell TeX how much it can adjust the value to improve the layout (that is they make the spacing elastic, thus the "rubber" designation). Reducing (or eliminating) the "plus" part of the rubber might help.
Watch out though, you can cause other layout artifacts if you constrain TeX too much.
Other things to think about:
The widow and club penalties probably apply section headings, and may be affecting TeX's layout choices (see https://stackoverflow.com/questions/512967/how-can-one-keep-a-section-from-being-at-the-end-of-a-page-in-latex for a discussion).
You may also want to consider messing with \baselineskip which controls the allowed spacing between lines of text and can also have rubber values.
This is a common problem, and there are probably some fairly sophisticated treatments already prepared on CTAN.
\vfill before the new section worked perfectly for me.

"spurious" leading in latex

the following latex input:
\rule{1cm}{1cm}\\
\rule{1cm}{1cm}
leaves a gap of about .35mm between the boxes. what is the length that defines this gap?
Edit: I was only partly right at first, but GoogleBooks knew. It pointed me at A Beginner's Book of TeX
By Raymond Seroul, Silvio Levy, Silvio Vieira Ferreira Levy, which says:
Three variables control this behavior \baselineskip, \lineskip and \lineskiplimit.
The default separation of lines is \baselineskip, but boxes are not allowed to come closer than \lineskiplimit. If they would, the vertical spacing is adjusted until \lineskip space lies between them...

Resources