The first one tries to continue even if there are errors and the second one stops at the first error and returns you to the terminal.

Hyphenation

LaTeX automatically hyphenates your words and keeps your text aligned along both margins. If you find that LaTeX incorrectly hyphenates a word (or doesn’t at all) you might suggest good places to break up the word by using (it will not show if not needed)

Maxwell just loved electro\-magnetism!

Useful settings to adjust how often LaTeX uses hyphenation are

\hyphenpenalty=5000 % penalty for hyphenation
\tolerance=1000 % tolerance for long spaces
between words

Hint: Use the package babel to tell LaTeX which language you are typing in for best hyphenation.

Structure of TeX-files

When writing large projects, your TeX file while probably soon contain thousands of lines and it will be a mess to find the right section or equation when you need to edit it. Not to worry! You can use \input{file} or \include{file} and keep your code in separate files.

\input works like copy-pasting the code into the document, which is perfect for including a preamble

\include is good for including different parts of your document, like chapters or sections. LaTeX will then use different AUX files (temporary files for compiling). This means that LaTeX only needs to re-compile the chapters that you have made some changes in. Unfortunately it can’t be nested, and will put your chapter or section on a new page.

Hint: When working on a single chapter you can use \includeonly to display only the output from certain included files. Since LaTeX then still will know about the other chapters using the AUX files you can still reference to equations and figures in the whole document and page numbers will be shown as in the full document.

Typography and encoding

Simple text files are handled very differently on different systems. During the stone age each character took one byte with the the possible values 0–255, which meant that characters like ßüåäö or 物理學 couldn’t commonly be used.

Nowadays most self-respecting operating systems use UTF–8 or better. I would recommend saving your files as UTF–8 and use \usepackage[utf8]{inputenc} in the beginning of your preamble to ensure compatibility with other systems.

LaTeX usually makes nice typography (kerning, spaces etc.). Useful packages to make it even better are:

Margins and papersizes

One common complaint about LaTeX is that it sometimes only fills a small portion of the page with large left and right margins.

This is done by purpose for allowing notes in the margins, but perhaps most importantly for easier reading. In the good old days computers only had 80 characters and 25 rows of width and height screen real estate, but many developers still stick with about 80 characters per line before they wrap to another line. It is much easier to read a text where you don’t loose track of which line you are reading as your eyes travel along a line.

The effect also depends on which paper size you use. In US and Canada the standard size is US Letter (216 x 279 mm) and in Europe the standard is A4 (210 x 297 mm).

To get nice margins and correct paper size use one of:

\usepackage[letterpaper]{geometry}
\usepackage[a4paper]{geometry}

Nice figures

Nice looking figures are very important for the overall impression of a document. To get good looking figures you need to make sure that they scale properly. There are basically two types of image formats: vector or raster (pixel). The former can be scaled indefinitely without pixelizing while the latter is basically made for one single scale. Example of vector formats are: PDF (some), EPS and SVG while JPG, GIF, PNG and BMP are raster.

To create good looking vector images I recommend using the latest versions of:

Xfig

Inkscape

Both programs can create images with equations or other LaTeX commands that will be interpreted when compiling the document.

latexmk

use for example latexmk main.tex which automatically runs all extra tools and compiles enough times for all references to get right.

It also has the awesome option of running continuously - let it run in the background and type away or edit an image, press save and latexmk will automatically recompile your document. This also enables it to optimize the compilation and will run faster than a complete recompilation.

Another amazing feature is the option -output-directory which enables you to put all the AUX, BBL, LOG et.c. files in a separate directory and keeps your working directory clean.

Packages and settings I use and why

Here is a quick list of my favorite packages and settings. See http://ctan.org/pkg/packagename for more information.

Put them in your preamble

\usepackage[colorlinks=true]{hyperref} to make references click-able.

\usepackage[hyphens]{url} to be able to write url:s easily: \url{http://myser.ver.com/~username/index.html}

\usepackage[colorinlistoftodos]{todonotes} to make todo:s, missing figures and todolists in document.

\usepackage[font=small,labelfont=bf]{caption} I like my captions to look different from the rest of the text.

\usepackage[section]{placeins} this makes sure that no figures are placed outside of their sections

units to correctly write physical quantities \unit[10]{Hz}

fancyhdr enables you to create nice headers and footers that are really useful when writing assignments if you don’t want a title page but still show a title and author in the header.

pdfpages to include whole pages of other PDF documents.

tensor to properly write the Riemann tensor without the indices displayed directly above each other

subcaption to be able to have several images (a, b, c) with different captions within the same figure.

\numberwithin{equation}{section} this will number your equaitons like (2.4) instead of (15).

For paragraphs I like \setlength{\parskip}{\baselineskip}\setlength{\parindent}{0pt} which gives makes paragraphs be separated by an empty line without indentation.