Swapping odd/even margin in Latex - latex

I'm writing something that I would like to print in Latex and I'm using the book documentclass.
The standard behaviour is to consider odd pages (so the rear of a double sided paper) as the beginning of chapters and document too, I would like to swap them to be able to have correct margins: on an even page right margin is greater than left one, I need the opposite..
Does a simple snippet exist to achieve this thing?
Thanks in advance

Margins can be modified using the geometry package. The inner and outer arguments to this package control the margins you want to change:
\usepackage[a4paper,inner=3.5cm,outer=2.5cm]{geometry} % Or w/e

Related

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 to align "pages of floats" to the top margin?

If I include [p] in the placement specifier of a \begin{figure} environment, figure floats may be placed on a dedicated page. However, at least in the "book" document class, floats are centered vertically on those pages.
How do I force all "pages-o-floats" to be aligned to the top margin (just like normal text pages)?
I believe your answer is in the UK TeX FAQ:
\#fptop defines the distance from the top of the page to the top of the first float
The simple fix is to reset \#fptop in your preamble:
\makeatletter
\setlength{\#fptop}{0pt}
\makeatother
However, you might find that this is a bit too high, so you might want something like 5pt instead. (Anyway, the FAQ entry is well worth reading; it explains in more depth what's going on than I am here.)
can you not use the [t] specifier instead of [p]?

Adding full page figures in Latex, how?

I have a full-page figure that LaTeX keeps putting at the end because of its size.
I would like it to be integrated on a separate page in the flow of text. How can I do it?
\begin{figure}[hbtp]
h = here
b = botom
t = top
p = page of floats
Algorithm will try the current position in document first, then bottom, then top and then on a seperate page. If you just specify 'h' you will force placement where the figure command is in the document. The order is encoded by you -- i.e., you could specify ptbh which would force a reverse order of evaluation.
p.s., I would strongly recomend anyone using latex to use lyx. Its just as powerfull as straight latex but its wysiwyg and you can drop to tex anywhere you want.
If you also want the caption to be rotated, you can also use
\usepackage{rotating}
\begin{sidewaysfigure}
That also eliminates the need for using angle=90 or something like that
\begin{figure*}[tb]
\centering
\makebox[\textwidth]{\includegraphics[width=.9\paperwidth]{./fig/fig5.eps}}
\caption{The SAP data model based on an UML class diagram: classes and relationships.}
\label{fig:Fig5}
\end{figure*}

Is there a way to get LaTeX to place figures in the same page as a reference to that figure?

I am using LaTeX and the figure environment.
I am well familiar with the parameters to that environment: [htbp], and I am also generally familiar with the strategies that LaTeX takes, by default, to decide where to put each figure. For example, by placing figures at the top or bottom of the page.
What I am wondering is whether there is a package, macro, or some commands that I can give so that if I have a single-column document and I mostly have a single in-text reference to a figure, that the figure would be more likely to be placed in the same page of the reference?
For example, imagine that I have a long paragraph which in the middle has a \ref{FIG:X}. When rendered, some of the paragraph appears before the page break, and some appears after the page break. I can also place the figure command somewhere before and after the whole paragraph. Is there a way to get it to actually be placed in the same page as the actual reference?
I don't want to sound too negative, but there are occasions when what you want is almost impossible without a lot of "artificial" tuning of page breaks.
If the callout falls naturally near the bottom of a page, and the figure falls on the following page, moving the figure back one page will probably displace the callout forward.
I would recommend (as far as possible, and depending on the exact size of the figures):
Place the figures with [t] (or [h] if you must)
Place the figures as near as possible to the "right" place (differs for [t] and [h])
Include the figures from separate files with \input, which will make them much easier to move around when you're doing the final tuning
In my experience, this is a big eater-up of non-available time (:-)
In reply to Jon's comment, I think this is an inherently difficult problem, because the LaTeX guys are no slouches. You may like to read Frank Mittelbach's paper.
Yes, include float package into the top of your document and H (capital H) as a figure specifier:
\usepackage{float}
\begin{figure}[H]
.
.
.
\end{figure}
You can always add the "!" into your float-options. This way, latex tries really hard to place the figure where you want it (I mostly use [h!tb]), stretching the normal rules of type-setting.
I have found another solution:
Use the float-package. This way you can place the figures where you want them to be.
I solve this problem by always using the [h] option on floats (such as figures) so that they (mostly) go where I place them. Then when I look at the final draft, I adjust the location of the float by moving it in the LaTeX source. Usually that means moving it around the paragraph where it is referenced. Sometimes I need to add a page break at an appropriate spot.
I've found that the default placement of floats is reasonable in LaTeX, but manual adjustments are almost always needed to get things like this just right. (And sometimes it isn't possible for everything to be perfect when there are lots of floats and footnotes.)
The manual for the memoir class has some good information about how LaTeX places floats and some advice for manipulating the algorithm.
If you want force this behaviour on all of your figures try
...
\usepackage{float}
\floatplacement{figure}{H}
...
Maybe this will help you?
\begin{center}
\includegraphics[scale=0.5]{picture_name}
\end{center}
I think is better to use the graphics command when your figures run away.
I have some useful comments. Because I had similar problem with location of figures.
I used package "wrapfig" that allows to make figures wrapped by text.
Something like
...
\usepackage{wrapfig}
\usepackage{graphicx}
...
\begin{wrapfigure}{r}{53pt}
\includegraphics[width=53pt]{cone.pdf}
\end{wrapfigure}
In options {r} means to put figure from right side. {l} can be use for left side.
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}
http://robjhyndman.com/researchtips/latex-floats/
One way I found that helps with this is to use \include{file_with_tex_figure_commands}
(not input)

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.

Resources