Check also out BibTeX tips
Fonts
Bold
\textbf{this text written with bold fonts}
Italic
\textit{this text is italic}
Include graphics and images (Windows)
If you use Yap to visualise DVI outputs from LaTeX code, graphics and pictures should be in the EPS format. Many plotting programs, e.g. Matlab, are able to write EPS files.
JPG and PNG files must however be converted to EPS. ImageMagick works well for command line operations on pictures but I haven’t figured out how to obtain EPS files of reasonable size with it: the size of the EPS output is an order of magnitude greater than that of the JPG input.
For JPG to EPS conversion I’m therefore using a program called jpeg2ps with the following syntax:
jpeg2ps -h -r 600 file.jpg > file.eps
where 600 is the resolution in dpi. This produces an EPS file of approximately double the size of the JPG input.
For PNG to EPS conversion I’m using a script/batch called png2eps with the following syntax:
png2eps file.png 400 600 file.eps
where the first number is the height in pixels and the second number the resolution in dpi. png2eps requires the following libraries: libtiff, netpbm and zlib. They are available both for Linux and Windows.
Apparently it is possible to tell LaTeX to automatically convert JPG files to EPS using jpeg2ps, but I haven’t managed to get it to work. It also seems possible to include JPG and PNG files directly by using the PGF package but I haven’t managed to get it to work (“no BoundingBox” error).
Include graphics and images (Linux)
sam2p works both with jpg and png, provided you have the right libraries installed.
sam2p file.jpg file.eps
Unfortunately converted sketches are aliased. Another problem is that sam2p does not handle partial transparency, which is something I tend to use when I draw png sketches. Therefore I ended up using png2eps for converting png files to eps.
Output to PDF
You can convert dvi to pdf with dvipdfm:
dvipdfm file.dvi
Norwegian alphabet (æ, ø, å)
If you want to write your TeX-file with the Norwegian alphabet, include the following line
\usepackage[latin1]{inputenx}
As far as I understand, the latin1 encoding works for all European languages. Note that the tex file must be encoded the same way. In Emacs, for example, this means loading the Latin-1 language environment. Add the following line to the .emacs file:
(set-language-environment "Latin-1")
Finally, if you’re writing in another language, you probably want the hyphenation and section names (e.g. “Chapter”) to follow this language’s rules. Use the babel package:
\usepackage[norsk]{babel}
Rotate figures and captions
\usepackage{rotating}
Replace
\begin{figure}, \end{figure}
with
\begin{sidewaysfigure}, \end{sidewaysfigure}
Remember to replace ”width” with ”height” (or the other way around) in the options of the \includegraphics
tag.
In a twoside (\documentclass[twoside]{...}
) document, the rotation depends on the page side.
It is also possible to rotate tables by using
\begin{sidewaystable}, \end{sidewaystable}
Headings
Headings are included with
\pagestyle{headings}
This way, chapter, section, … titles are written at the pages top.
Some titles may be too long for the page width. One possibility is to include a short version in brackets when declaring the corresponding section:
\chapter[Short title]{This is a very long title}
The short title is also what will appear in the table of contents. The same syntax may be used with the \caption
tag to write a shorter caption for the list of figures / tables.
Add References to the table of contents
Unless you write the following, there will be no References / Bibliography entry in the table of contents:
\addcontentsline{toc}{chapter}{Bibliography}
You may want to write similar lines for other numberless parts (e.g. Nomenclature)
Margins
Use vmargin package.
\setmargrb{30mm}{30mm}{30mm}{35mm}
% left margin, top margin, right margin, bottom margin
For small margins:
\usepackage{fullpage}
List of figures / tables layout
The “report” template, which I’ve been using, sets the size of the space between the figure / table number in the corresponding list to 2.3em. That is narrow if you have figures numbered N.xx, let alone N.xxx. You may widen the space by adding the following lines somewhere before the \listoffigures command:
\makeatletter
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3.3em}}
\makeatother
The \makeatletter ... \makeatother
command is necessary because the renewed command—\l@figure
—contains an @.
In the example above the space is set to 3.3em.
Non-breaking hyphen and minus sign
From what I understand, non-breaking hyphens are written like this:
\mbox{-}
and non-breaking minus signs like this:
\mbox{--}
Inline equations
Inline equations are put between $-signs:
$x = 5$
is an inline equation
An inline equation requires more than one line of vertical space, e.g. with fractions will look bad unless you write:
\displaystyle
in the beginning of the equation.
Indentation of equations
By default, equations are horizontally centered. In order to align equations to the left of the page, instead, add the ‘fleqn’ option to the document class:
\documentclass[fleqn]{article}
If you want to indent equations from the left, you must also specify the value of the ‘mathindent’ variable:
\setlength{\mathindent}{1cm}
Vertical space
\vspace{2cm}