LaTeX/FAQ

LaTeX logo.svg

LaTeX

Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Importing Graphics
  14. Floats, Figures and Captions
  15. Footnotes and Margin Notes
  16. Hyperlinks
  17. Labels and Cross-referencing

Mechanics

  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Texts

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Letters
  2. Presentations
  3. Teacher's Corner
  4. Curriculum Vitae

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics

Programming

  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Themes

Miscellaneous

  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks

Appendices

  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC

Margins are too wideEdit

LaTeX default margins may seem too large. In most cases, this is a preferred default and improves readability.

If you still disagree, you can easily change them with

\usepackage{geometry}
% or
\usepackage[margins=1.5in]{geometry}

See Page Layout.

Avoid excessive double line breaks in source codeEdit

Too many paragraphs of one line or two do not really look great.

Remember the TeX rule.

  • If two or more consecutive line breaks are found, TeX starts a new paragraph.
  • If only one linebreak is found, TeX inserts a space if there is no space directly before or after it.

You might be tempted to put blank lines all the time to have a clear source code. This will have an impact on formatting.

The trade-off is simple: put a comment at the very beginning of the blank lines. This will prevent TeX from seeing another line break, all characters up to and including the next line break after a comment are ignored.

Example:

We are in the first paragraph here.
%
We are still in the first paragraph.

This time, this is another paragraph.

Simplified special character inputEdit

So long as your computing environment supports UTF-8, you can enter special characters directly rather than entering the TeX commands for diacriticals and other extended characters. E.g.,

R\'esum\'e can also be written résumé.

This requires:

  • your text editor supports and is set to save your file in UTF-8;
  • add the \usepackage[utf8]{inputenc} line in the preamble.

Avoid using latin1. See Special Characters.

Writing the euro symbol directlyEdit

Yes this is possible. Add to following lines in your preamble.

\usepackage[utf8]{inputenc}
\usepackage{marvosym}
\DeclareUnicodeCharacter{20AC}{\EUR{}
}

LaTeX paragraphs title and content on the same lineEdit

Most new users do not like that \paragraph{...} writes the title on the same line as the content. This is not weird at all, it is very common in a lot of documents.

The solution is not to hack LaTeX, but to get used to it instead. Remember, LaTeX does the formatting with a high respect to typography, and typography is not simple. So when LaTeX and the user disagree, LaTeX is mostly right.

Still, there is a solution for the obstinate user. See Paragraphs line break.

Fonts are ugly/jagged/bitmaps or PDF search fails or Copy/paste from PDF is messyEdit

You must be using diacritics (e.g. accents) with OT1 encoding (the default). Switch to T1 encoding:

\usepackage[T1]{fontenc}

If you have ugly jagged fonts after the font encoding change, then you have no Type1 compatible fonts available. Install Computer Modern Super or Latin Modern (package name may be lm). To use Latin Modern you need to include the package:

\usepackage{lmodern}

See Fonts for an explanation.

Manual formatting: use of line breaks and page breaksEdit

You should really avoid breaking lines and pages manually. The TeX engine is in charge of that. The big problem with manual formatting is that it is not dynamic. If it looks right on the first place, the content is likely to render really badly if you change anything before the point you manually formatted.

The only place where page breaks are recommended is at the upper level of sectioning in your documents, e.g. parts or chapters.

Besides you should use \clearpage or \cleardoublepage which print currently floating figures before starting a new page.

Always finish commands with {}Edit

TeX has an unintuitive rule that if a control sequence (a command) is not followed by a pair of braces (with a parameter in between or not), then following spaces characters are ignored. They don't print any space, and the command (say, the TeX or LaTeX logos) are run together with the following word.

Solution: always use braces, even without parameters. Example:

\LaTeX is great. % BAD !
\LaTeX{} is great. % GOOD !

Explanation: a control sequence name can only be composed of characters with catcode 11, that is A-Z and a-z by default. TeX knows where the control sequence name start thanks to the backslash, and it knows where it ends when it encounters the first token which is not of catcode 11. This character is then skipped. Since consecutive spaces have been concatenated into one single space, no space is taken into account.

It is possible to define macros that will insert a space dynamically thanks to the xspace package.

  • If there is no brace and a space following the command, an extra space will be appended.
  • If there is braces, no extra space will be printed.

Example:

\usepackage{xspace}
\let\latexold\LaTeX
\renewcommand{\LaTeX}{\textrm{\latexold}\xspace}
...
\LaTeX is followed by a space.
\LaTeX{} is followed by a space.
\LaTeX{
}is not followed by a space.

Forget about bold and underlineEdit

Typographically speaking, it's a poor practice to use bold or underline formats in the middle of a paragraph. Yes, it is very common for traditional document processors because these two functions are the most accessible ones along italic shape.

However, bold and underline tend to overweight the text, and distract the reader. When you start reading a paragraph with a bold word in the middle, you usually read the emphasized first, thus spoiling the content and breaking the order of the ideas.

The point is to emphasize a word or a part of a sentence. Use italic for that. It does not overweight the text nor distract the reader.

The original use of bold and underline is for special parts, such as sectioning, index, glossaries, and so on. Actually underlining is rarely used in professional environment.

LaTeX has a macro \emph{...} for emphasizing text. It should be preferred to \textit{...} because it is dynamic. An emphasized text inside another emphasized text will print it in the regular font. You cannot do that with \textit{...}.

Final word: with LaTeX only use \emph{...} for common text.

The proper way to use figuresEdit

Users used to WYSIWYG document processors like Word or LibreOffice usually get frustrated with figures. The answer is simple: a figure is not a picture!

If you use \includegraphics without enclosing it in a figure environment, it will behave just as what you were used to, it will place the picture in the source order.

Figures are a kind of floats, which are virtual objects that follow specific rules to be printed in a professional style in the document. This is a convenient way to prevent cluttering your text with pictures and tables.

See Importing Graphics and Floats, Figures and Captions for more details.

Text stops justifyingEdit

You used \raggedleft, \raggedright or \centering at some point. These commands are switches, they remain active until the end of the scope, or until the end of the document if there is no scope. See Paragraph Alignment.

Rules of punctuationEdit

LaTeX does some work for you, but not everything. Especially regarding punctuation, you are pretty free to do what you want. Punctuation rules are different following the language. In English, there is no space before a punctuation mark, and one space after it.

There are a lot of rules, but you can have a quick look at Wikipedia.

Compilation fails after a Babel language changeEdit

This is a limitation of Babel. Delete the .aux file (or clean the project).

Learning LaTeX quickly or correctlyEdit

Nowadays it is very common to learn on the web, using a search engine and picking stuff here and there. As with every programming language, we really oppose this method, which will only lead to lack of control, unexpected results and a lot of frustration. Learning LaTeX is not hard at all, and it is not that long. Most chapters in this book are dedicated to a specific usage, so the basics are actually covered very quickly.

If you are getting frustrated with a specific package, make sure you read its official documentation, which is usually the best source of information. Content found on the web, even on this book, is (almost) never as accurate as the official documentation. Inaccurate help might just result in the opposite effect: letting you make mistakes without understanding why.

The time you spend learning is worth it, and quickly makes up for the time you would have lost if you hadn't learned things properly, being stuck all the time.

Non-breaking spacesEdit

This essential feature is a bit unknown to newcomers, although it is available on most WYSIWYG document processors. A non-breaking space between two tokens (e.g. words, punctuation marks) prevents processors from inserting a line break between them. It is very important for consistent reading.

LaTeX uses the '~' symbol as a non-breaking space.

You usually use non-breaking spaces for punctuation marks in some languages, for units and currencies, for initials, etc.

In French typography, you would put a non-breaking space before all two-parts punctuation marks. Example:

Il répondit~: «~Ce pain coûte-t-il 2~€~?~»

Note that writing French like this might get really painful. Thankfully, Babel with the frenchb option will take care of the non-breaking spaces for all punctuation marks. In the above example, only the non-breaking space for the euro symbol must remain.

Smart mathematicsEdit

All virtual objects designated by letters, variables or others should use a dedicated formatting. For math and a lot of other fields, the LaTeX math formatting is perfect. For instance, if you want to refer to an object A, write

Speaking of $A$, let's say...

If you want to refer to several objects in a sentence, it is the same.

Speaking of $A$, $B$ and $C$...

If you refer to a set of objects, you can still use the math notation.

The family $(A, B, C)$ is...

Note that this is different from usual text parentheses.

A sentence. ($A$, $B$, and $C$ are not concerned, but we do not mean the $(A, B, C)$ family.)

Use vector graphics rather than raster imagesEdit

Raster (bitmap) graphics scale poorly and often create jagged or low-quality results which clash with the document quality, particularly when printed.

Using vector (line-oriented) graphics instead, either through LaTeX's native diagramming tools or by exporting vector formats from your drawing or diagramming tools, will produce much higher quality results. Generally, you should use PDF, EPS, or SVG graphics rather than PNG or JPG.

Stretching tablesEdit

Trying to stretch tables with the default tabular environment will often lead to unexpected results. The nice tabu package will do what you want and even much more. Alternatively if you cannot use the tabu package you may try tabularx or tabulary packages See Tables.

Tables are easier than you thinkEdit

Even though the Tables chapter is quite long, it is worth reading. In the end, you only need to know a few things about the environment of your choice.

Besides, some LaTeX editors feature table assistants. Finally, many spreadsheet applications have a LaTeX export feature (or plugin). Again, see Tables for more details.

Relieving cumbersome code (lists and long command names)Edit

LaTeX is sometimes cumbersome to write, especially if you are not using an adequate editor. See Editors for some interesting choices.

You may define aliases to shorten some commands:

\usepackage{xspace}
\newcommand\tss[1]{\textsuperscript{#1}}
\newcommand\tbs[1]{\textbackslash\xspace
}

Here the xspace package comes in handy to avoid swallowed spaces.

For lists you may want to try the easylist package. Now writing a list is as simple as

\usepackage[ampersand]{easylist}
% ...

\begin{easylist}
& Item 1
& Item 2
&& Subitem 1
&&& Subsubitem 1
& Item 3
&& Subitem 1
\end{easylist
}

Reducing the size of your LaTeX installationEdit

The Installation article explains in detail how to manually install a fully functional TeX environment, including LaTeX and other features, in under 100 MB.


Previous: Export To Other Formats Index Next: Tips and Tricks
Last modified on 17 April 2014, at 22:07