# *nix tips

## 2008-04-15

### Various LaTeX tips

I decided to bring together LaTeX tips from my other blog.

#### How to change line spacing?

To change spacing between baselines:
% to set one-and-half spacing
% put before \begin{document}
\renewcommand{\baselinestretch}{1.5}
More flexible way is provided by setspace package. It allows to change line spacing for parts of the text. To use the package, add before \begin{document}:
\usepackage{setspace}
\onehalfspacing % one-and-half spacing globally
% or \singlespacing % normal spacing
% or \doublespacing % double spacing
% or \setstretch{factor} % arbitrary spacing
Then after \begin{document} you can use onehalfspace and doublespace environments:
\begin{onehalfspace}
This text will be set with one-and-half line spacing.
\end{onehalfspace}
\begin{doublespace}
This text will be set with double line spacing.
\end{doublespace}

#### How to change margins?

The easiest way is to use geometry package, add before \begin{document}:
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
To change layout and margins of the particular pages use chngpage package.

#### How to fit the text on one page?

First, try to \enlargethispage:
\enlargethispage{2\baselineskip} % add two more lines to this page
\pagebreak % finish the page
If you want to shrink the text, use the “starred” version \enlargethispage*{length}:
\enlargethispage*{\baselineskip}

#### How to rotate a page?

Use lscape package and the landscape environment it provides to rotate arbitrary pages. This may be useful to fit wide tables or figures:
% before \begin{document}
\usepackage{lscape}
% after \begin{document}
...
\begin{landscape}
...
This text will appear on a rotated, i.e. landscape, page.
...
\end{landscape}

#### Why figure numbering is wrong?

Check your figure environment. \label should always go after \caption. \caption first, \label second. The right template for the figure is:
\begin{figure}
... % insert your figure here
\caption{Caption text}
\label{fig:myfigure}
\end{figure}
\makeatother
\todo{rewrite this}
\listoftodos