470

I'm getting the impression from reading the answers written by some of the real experts here that there are quite a few little packages that just tweak LaTeX2e's default behaviour a little to make it more sensible here and there.

Rather than try to pick these up one by one as I read answers to questions (and thus risk missing them), I thought I'd ask up front what LaTeX2e packages people load by default in (almost) every document.

As this is a "big list" question, I'm making it CW. I don't know if there are standard rules across all SE/SO sites for such questions, but on MathOverflow the rule is generally: one thing (in this case, package) per answer. I guess that if a couple of packages really do go together then it would be fine to group them.

This is perhaps a little subjective and a little close to the line, so I'll not be offended if it gets closed or voted down! (But please explain why in the comments.)

Also see our community poll question: “I have used the following packages / classes”

6
  • There are standard rules across all SE sites, see meta.stackexchange.com/questions/11740/… and follow the links. The idea is that the answer to a "what are good default packages" question is way too big for a single user to write, so the community helps out. The one accepted answer that everyone edits has lots of edits from lots of people. Anton Geraschenko of MO made his own very different interpretation, "post one resource per answer" (mathoverflow.net/faq#communitywiki), and we'll have to decide one or the other. Commented Jul 29, 2010 at 22:25
  • 8
    Personally, I'd find a single list, separated by headings (Ex. Format, Math, Bib,Images, Other for this question), with a list of everyone's packages and how they're different from other packages in the section much more readable and useful. That amsmath is the highest voted just says that the MO community is here in full force. The less-known, but equally relevant formatting packages linked by Vivi, Joseph, and András are invisible without a lot of scrolling and reading. Commented Jul 29, 2010 at 22:37
  • 6
    I think the list of one package per answer is a good idea, as we can vote on individual packages... Commented Jul 30, 2010 at 11:30
  • My intention was not so much to find an ordering, but rather to find if there are any that I'd never heard of. It's not working out quite as I'd hoped, but I'm not sure if its possible to fix it at this stage (or worth doing). Commented Jul 30, 2010 at 11:37
  • 1
    It can be good to have a single answer that is just an index of all the other answers, and accept that, so that it floats to the top.
    – naught101
    Commented Aug 30, 2012 at 3:44

65 Answers 65

20

This has been mentioned in some of the “big answers”, but thought it deserved special attention. Probably most documents should include:

\usepackage[T1]{fontenc}

This is to resolve some deficiencies and inconsistencies of the default OT1 font encoding; while improving the support of special characters (e.g. the ability to copy&paste from the generated pdf document).

18

A nice commenting environment is provided by the package:

\usepackage{verbatim}

For debugging purposes I find this package indispensable. Before I found this package I would have to enter % before each line I wished to comment. The environment works as follows:

\begin{comment}
Text in this environment will be ignored by LaTeX.
\end{comment}

The packages

\usepackage{comment}
\usepackage{xcomment}

provide even greater commenting capabilities (i.e. the ability to selectively typeset certain environments) though I personally haven't had much use for these extended features.

3
  • 7
    In any decent editor, you can easily comment out/in several lines at once. Due to that, I find the usefulness of the comment environment greatly reduced – i.e. I don’t use it at all. Commented Sep 11, 2010 at 8:14
  • 6
    I simply use \newcommand{\comment}[1]{}. Put \comment{ before the block and } after to comment out any part of the file. Commented Sep 11, 2010 at 10:45
  • I was absolutely amazed to find out that Kile actually natively supports this and thus displays everything in the comment environment as if commented out by %.
    – Christian
    Commented Jul 1, 2013 at 2:58
18

I save my documents in an SVN repository. The svn package helps to extract some informations out of the version control system. The document has somewhere a hint what revision number and what date it is. For this you have to set svn keywords and declare in your LaTeX document what you need:

\SVN $LastChangedRevision$
\SVN $LastChangedDate$

Wihtin the document you can refer to that information with \SVNLastChangedRevision and \SVNDate.

3
  • Do you know if you can you do that with hg?
    – philosodad
    Commented Dec 29, 2010 at 4:57
  • I don't work with hg (or just began a few days ago :-)). So I have no idea if it does.
    – qbi
    Commented Dec 29, 2010 at 9:58
  • Also consider svn-multi which allows you to access more svn data tat I use in version footers.
    – DGarside
    Commented Mar 14, 2012 at 21:39
16

As long as this list is, minted is missing. For code syntax highlighting it works really well and includes the long list of languages of pygments. The pieces of code end up looking like this:

\begin{minted}{language}  
code
\end{minted}

In Beamer it requires frames to be marked as [fragile], and it takes some skill to set it up on Windows. But the results are well worth the effort.

2
  • Could you tell us about its advantages compared to lstlisting which seems to be the most commonly used syntax highlighting package?
    – Christian
    Commented Jun 27, 2013 at 19:01
  • 3
    @Christian: the main difference is that you can tap directly into pygments, which is a (very) well maintained source for syntax colouring for many languages and is used in many places other than LaTeX. There is a full discussion on the differences between lstlisting and minted here: tex.stackexchange.com/questions/102596/…,
    – FvD
    Commented Jun 28, 2013 at 13:17
15
\usepackage{fancyvrb}

I use it for highly customisable verbatim. The abstract of the package documentation reads:

This package provides very sophisticated facilities for reading and writing verbatim TeX code. Users can perform common tasks like changing font family and size, numbering lines, framing code examples, colouring text and conditionally processing text.

Here's an example using the SaveVerbatim environment in combination with the \fcolorbox command: enter image description here

14

Usually I write German texts. We have new and old rules for spelling. The package hyphsubst provides some new hyphenation pattern. That's why I load it in addition to babel:

\RequirePackage[ngerman=ngerman-x-latest]{hyphsubst}
1
  • Is this something that is still needed in 2019? Commented Sep 13, 2019 at 14:45
14

I'm not just feigning surprise when I say I'm shocked that such an incredibly useful package set as xparse/expl3 (the latter is loaded by the former) hasn't been mentioned yet. I invariably find myself typing:

\documentclass{article}
\usepackage{xparse}

to begin a document.

3
  • 10
    So, what does it do?
    – fifaltra
    Commented Dec 24, 2013 at 0:32
  • 3
    with xparse, one can define commands and environments with multiple optional arguments before, between, and after mandatory arguments. Several new type of arguments can be defined, starred commands, and much more.
    – Michael P
    Commented May 7, 2014 at 10:17
  • Somebody else has also posted this later on (but with more/different detail) as tex.stackexchange.com/a/238482/78134
    – owjburnham
    Commented Jul 18, 2017 at 15:08
13

This question assumes you are making a LaTeX document for personal use. If you are planning to submit the document to a journal, it's safer to avoid using too many unusual classes, because they may be incompatible with the journal's LaTeX classes or may be incompatible with the style that the journal will impose on your paper. Very common packages like amsthm are usually safe. (I would leave this as a comment, but I don't have enough reputation yet.)

1
  • 7
    Yes and no. Given that I rarely know what paper it is intended for when I start writing a paper, and given how useful some of these packages are, I include them all and try to get away with it! Sometimes I'm successful, sometimes I need to include the package .sty file along with my submission. Commented Aug 4, 2010 at 7:03
13

I also find package lipsum fun to use. It lets you generate several versions of lorem ipsum placeholder text to see what your document would look like.

2
  • Very useful when preparing drafts or templates but not only. Commented Nov 10, 2014 at 21:53
  • 2
    blindtext is much more mighty, it has several languages and can use some example math.
    – MaxNoe
    Commented Jan 17, 2015 at 14:01
12

Edited by doncherry: Removed packages mentioned in separate answers.

I use TeX for a variety of documents: research papers, lectures/tutorials, presentations, miscellaneous documents (some in Japanese). Each of these different uses, requires different packages.

Depending on my mood, I like to use different fonts. A particular nice combination for mathematics papers is

\usepackage[T1]{fontenc} % better treatment of accented words
\usepackage{eulervm}   % Zapf's Euler fonts
\usepackage{tgpagella} % TeXGyre Pagella fonts

For references,...

\usepackage[notref,notcite]{showkeys} % useful when writing the paper
\usepackage[noadjust]{cite} % [1,2,3,4,5] --> [1-5]  useful in hep-th!
\usepackage{hyperref} % hyperlinks, metadata,...

For lecture notes (again mathematical) I often like to section the document into "lectures" instead of sections and to add some colours to the titles,.... To do this it's useful to use

\usepackage{fancyhdr} % fancy headers
\usepackage{titlesec} % to change how sections are displayed
\usepackage{color}    % to be able to do this in colour

and I also like to decorate using some silly glyphs, for which these fonts are useful:

\usepackage{wasysym,marvosym,pifont}

and also box equations and other things

\usepackage{fancybox,shadow}

I like adding pictures, whence

\usepackage[rflt]{floatflt}
\usepackage{graphicx,subfigure,epic,eepic}

You may want to hide the answers to tutorial exercises, problems,... and this can be achieved with

\usepackage{version,ifthen} % ifthen allows controlling exclusions

I use XeLaTeX for documents containing Japanese, which works better with

\usepackage{fontspec} % makes it very easy to select fonts in XeLaTeX
\usepackage{xunicode} % accents
6
  • 9
    As the question suggested, could you write an answer per package/topic and explain what these packages do or why do you need them? Commented Jul 29, 2010 at 10:51
  • 1
    can you please add comments like \ usepackage{foo} % to get following features within your code?
    – Dima
    Commented Jul 29, 2010 at 11:06
  • Sorry -- misread the format of the question. I'll break my answer up later today. Commented Jul 29, 2010 at 12:13
  • 1
    To avoid breaking them up all the way, you could try grouping them a little (say, if there's one package that you wouldn't consider using without another one then put them together). Commented Jul 29, 2010 at 13:04
  • @Andrew: Why avoid breaking them up all the way? We'd probably end up with more pages, but I really like the many tiny discussions of packages in this question, which lead to concise tips how to implement a certain package optimally etc. Should this be discussed on meta?
    – doncherry
    Commented May 5, 2011 at 7:40
11

For the natural scientists among us, the package mhchem makes it very easy to typeset chemical symbols and chemical equations.

1
10
\usepackage[scaled=0.8]{luximono} 

which is a fixed-width font which supports boldface. This is useful when typesetting source code.

10
\usepackage{docmute}

I use this in my syllabus preparation as I can make each of the subordinate documents fully standalone, yet do a complete compile of everything at once to verify I have all the corrections made.

It does require that all of the preambles are identical.

This then allows me to work only on one course syllabus or schedule or homework assignments with very fast compiles. Also during the semester I can do corrections on individual documents.

My main document preamble is

\documentclass[10pt,letterpaper]{article}
\input{commonpreamble}
\usepackage{docmute}
\begin{document}

And the subordinate documents have this preamble

\documentclass[10pt,letterpaper]{article}
\input{commonpreamble}
\begin{document}

Notice: Only one master document and the \usepackage{docmute} is only in that file.

Also all subordinate document must be only loaded with \input or \include from the main document. Only one level down is allowed.

I keep one copy of the preamble as commonpreamble. And all files are kept in one folder. This system works very well with Texmaker or TexStudio as the structure of the document is always displayed regardless of choosing a "Master Document".

1
8

I just discovered the xparse package. It lets you define more flexible macros with more than one optional argument. I used it to make a very general partial derivative function.

\usepackage{xparse}
\DeclareDocumentCommand{\pder}{ O{} O{} m }{\frac{\partial^{#2}#1}{\partial#3^{#2}}}

Example

\pder{x} will give you

enter image description here

\pder[f]{x} will give you

enter image description here

\pder[f][3]{x} will give you

enter image description here

3
  • Also posted as tex.stackexchange.com/a/121259/78134
    – owjburnham
    Commented Jul 18, 2017 at 15:07
  • You currently have \pder[f][3]{x} yielding $\dfrac{\partial^2 f}{\partial x^2}$. Is that a typo, or is the numbering really off by one?
    – LSpice
    Commented Jan 10, 2019 at 2:27
  • @LSpice Probably a typo. It been a long time since i made this post. But do try it out and let me know.
    – Rud Faden
    Commented Jan 10, 2019 at 8:20
8

It has been forgotten the excellent tcolorbox package which allows to customize the boxes, to create customized box environments, box commands, backups.

Its possibilities are very great, its doc is about 500 pages long, but since I use it, the writing of my handouts has become much easier.

tcolorbox – Coloured boxes, for LATEX examples and theorems, etc

7

I usually use relsize package. It's easy to use it. It changes the font size of part of your text. Just type \relsize{x} where x is the number of steps you want to move through the hierarchy of font sizes.

1
  • 1
    it's a mystery to me why relsizes are not the default size changing commands. probably historical.
    – ivo Welch
    Commented Jan 2, 2016 at 17:11
7

When using class book, I always load package emptypage.

It needs no particular skill since it doesn't introduce any new command to use, it removes headers and footers from empty pages at the end of chapters just by adding \usepackage{emptypage} in your preamble.

The default option is odd.

7

In almost every document I use the csquotes package in combination with babel. The handling of quotations with \enquote{} and the flexibility of changing the way the quotation marks look like is very convenient. See for example, the answer to the question Quotation Mark Pairing.

6
 \usepackage{etex}

to be able to include e.g. TikZ without strange errors.

UPDATE: not needed with LaTeX releases since 2015 (source: https://tex.stackexchange.com/a/186594/1340).

2
5

The following command before the \documentclass command permits Computer Modern fonts at arbitrary sizes: \RequirePackage{fix-cm}.

5

I always use

\usepackage[retainorgcmds]{IEEEtrantools} % sophisticated equation arrays

It offers a sophisticated environment for formatting equation arrays,IEEEeqnarray and also offers a few other constructions. I don't use the traditional eqnarrays any more. I usually set the option [retainorgcmds] because it prevents the package from overwriting the itemize, enumerate and description definitions.

Check out How to Typeset Equations in LaTeX. The author gives some good examples of how and why to use this package instead of the traditional ones. The Not So Short Introduction to LaTeX 2ε also mentions the package in section 3.5.2. This section actually seems to be a copy of the first link ;)

5

No one mention tabulary.

Sometimes I make tables with multiline cells in several columns, where the total width must be just \textwidth. Use tabular with p{} columns here is a pain since one must take into account \tabcolsep.

For this, the sibling tabularx (cited in another answer) could make a good work ( X columns take all the available space), but often I need columns weighted according to the amount of text rather and with different alignments, but X columns of tabularx share equally that space.

Instead, tabulary allow the use L, C, R and J columns o automatic variable width. Not always a column layouts as LLCRL produce the desired result but since it is possible mix L,C,R columns with basic types (l,r,c,p{}, m{}...) find the best fit (i.e., some like Lcp{5em}RL) is a child play.

1
  • Or try the newer tabularray.
    – Bart
    Commented May 20 at 15:18
5

I am surprised that nobody mentioned the packages:

  • physics which offers numerous commands to make typing of physics equations faster, simpler and equations easier to read. See the docs
  • cleveref gives nice commands for easier referencing within the document. Note, this package is to be loaded after hyperref See also the docs
2
4

When I'm writing package documentation using ltxdoc it likes using three columns for the index. I'd prefer two. I fix it with the idxlayout package:

\usepackage[columns=2]{idxlayout}
4

I always load the package xy to produce diagrams.

Also tikz to draw figures.

1
  • 7
    I use tikz-cd to get commutative diagrams drawn with tikz with a syntax highly reminiscent of the xy syntax. Commented Dec 6, 2012 at 3:22
4

I include: \usepackage{outlines} in my preamble. outlines is a quick and easy way to generate hierarchically embedded lists. Especially useful when I'm drafting up a paper (I like to outline it) or if I'm quickly typing up notes, e.g., at a conference.

1
  • 1
    Could you add a minimal working example as a demo and a picture of the output?
    – doncherry
    Commented Feb 23, 2014 at 14:51
4
\usepackage{mciteplus}

Allows you to combine multiple references: \cite{refa, *refc, *refc, refd} will produce one references with refa, refb, and refc combined (if they are not used independently elsewhere).

2
4

I am using the chemfig and chemmacros packages everyday and they are great for drawing chemical structures and reaction schemes. Both are really good documented and play nice together.

example from manual

There are also nice third party tools like mol2chemfig for faster structure drawing instead of writing every bond and atom on your own. (example)

Just to mention another package for chemistry, one could also use XyMTex but heterocyclic compounds look quite ugly.

3

Very often a requirement for the documents I write is that the font should be Times (or Times New Roman), so the package I use to set the main roman font to Times and acceptable math is mathptmx.

Recently, I have experimented with newtxtext and newtxmath but, personally, I do not like the design of some symbols and there are a few cases where the spacing between characters is too tight.

For personal use I set the font to New Century Schoolbook and Fourier (for math) with the fouriernc package.

1
  • I use the newtxmath in conjunction with libertine, and love it. It is great to have upright Greek letters, which fits better to the font as the letters from the upgreek package do. Also the upright \partial is great, because operators in mathematic should be written upright.
    – Michael P
    Commented May 7, 2014 at 10:24
3

pageslts: for being able to refer to the last page of a document

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .