Techniques and packages to keep up with good practices

General tips

  1. Use as few packages as possible,
  2. Call the packages in particular order,
  3. Use many small documents instead of one big one,
  4. Comment your code,
  5. Write readable code,
  6. Concentrate on the content, not on the appearance.

General tips somewhat explained

  1. That's because packages tend to conflict and go obsolete. (See How to keep up with packages and know which ones are obsolete?)
  2. Some packages require (or are recommended) to be called before/after other packages. Some must be called among the last, some among the first. (See Packages that need to be included in a specific order)
  3. This means using \include{} and/or \input{} commands to compose all the small pieces (chapters, sections, etc.) into one continuous document. (See When should I use \input vs. \include?). [The rationale in this point is to keep the code clean and short (rule 5) in your master document. Then you can focus on content of each piece of the document (rule 6).] A benefit of this point is that you can get to set shortcut commands to use in all documents in a .tex file in your path, and then \input it in the preamble of any/all documents. This can make for a very large document to keep short at the eye at an initial stage of reading the master document pretty much like a short mwe.

  4. If one forgets what particular block of code does, reading the comments will help by the fastest possible way.

  5. This means short lines, appropriate line indentation, using \newcommand to define (mnemonic) commands for repetitive math expressions, etc.
  6. Hack little, think more, write on the subject. Appearance without content is nothing.

And probably other things ...


  • Programing
    • fixltx2e is essential
    • etoolbox provides some functionality that one can only get from hacking LaTeX kernel or using the internal macros otherwise. Also it provides some useful document and environment hooks
    • xspace is a tiny but useful macro for defining text oriented macros
    • geometry, typearea, etc, use one and only one of them. The same principle apply for titlesec, fancyhdr, etc. In principle, avoid using packages provide similar functionality at the same time, especially when one of them hack the LaTeX kernel. Use the best of them only ("best" for you anyway).
  • Typography
    • booktabs is essential for professional look tables. Also avoid using vertical lines. In fact you should never use vertical lines and limit the use of horizontal lines
    • for typographical consideration, consistency is far more important than details. For example if you use \begin{tabularx}{\textwidth}{...}..., use it everywhere. Make all tales have the same feel.
    • figures, either from external software of using packages like tikz, produce them with the size they are meant to be. Try to avoid using \includegraphics[scale=...], etc
    • use \DeclareMathOperator, don't use \mathrm whenever suitable
    • use colors carefully, again, consistency is better than fancy. Define a few colors and stick with them only.
    • Use different weight, different size, different shapes, different font families, to present different things. But use one and only one of them. For example, don't use a bold large sans serif for heading, just bold, or just large, or just sans serif, or simple capitals of the body fonts.
    • Last not least, "every typographical rules can be broken, as long as you know the rule".

  • Loading the strict package prevents using LaTeX's declarations as environments.

  • Loading the fixltx2e package fixes some LaTeX2e errors.

  • fixmath changes LaTeX's default math style to comply with some international standards, specifically regarding Greek letters, see package description.

  • There are many packages improving LaTeX's standard behavior, for example setspace and booktabs, and packages supporting typographic requirements/ styles and quality, such as siunitx and microtype, so preferring them over LaTeX standard features would be best practice. Recommended packages can be found here: What packages do people load by default in LaTeX.