466

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”

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
  • There are standard rules across all SE sites, see http://meta.stackexchange.com/questions/11740/what-are-community-wiki-posts-on-stack-overflow 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" (http://mathoverflow.net/faq#communitywiki), and we'll have to decide one or the other. – Kevin Vermeer Jul 29 '10 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. – Kevin Vermeer Jul 29 '10 at 22:37
  • 6
    I think the list of one package per answer is a good idea, as we can vote on individual packages... – Amir Rachum Jul 30 '10 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). – Andrew Stacey Jul 30 '10 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 Aug 30 '12 at 03:44
  • @naught101 I'd thought of making into a blog post, actually. If a single answer then someone else will have to do it since if I do it and accept it then it won't float to the top. – Andrew Stacey Aug 30 '12 at 08:02

65 Answers65

283

I almost always load microtype. It plays with ever-so-slightly shrinking and stretching of the fonts and with the extent to which text protrudes into the margins in a way that yields results that look better, that have fewer instances of hyphenation, and fewer overfull hboxes. It doesn't work with latex, you have to use pdflatex instead. It also works with lualatex and (protrusion only) with xelatex.

Robert
  • 14,181
  • 1
  • 52
  • 77
vanden
  • 30,891
  • 23
  • 67
  • 87
230

The family of AMS math packages. At least amsmath and amssymb. Also amsthm if I need theorems and the class I'm using doesn't already define them.

Particularly for writing equations, the AMS packages define a rich set of environments to group and align formulas in many different and useful ways. I also like that it encourages the use of semantic commands (e.g. the cases environment) over syntactic commands (e.g. a \left\{ followed by an array).

Its documentation can be found running texdoc amsldoc on a command line.

Stefan Kottwitz
  • 231,401
Juan A. Navarro
  • 62,139
  • 32
  • 140
  • 169
  • 7
    In particular, amsthm provides an easy way to set up different theorem styles, amsmath provides the \text command, and amssymb contains several often-used symbols. – András Salamon Jul 29 '10 at 12:40
  • Also amsfonts, which provides some (partial) fonts which are frequently used in math. – Mark Meckes Jul 29 '10 at 13:49
  • 25
    +1 for the (oblique) reference to texdoc. I only discovered that recently and I wonder how I ever lived without it! – Andrew Stacey Jul 29 '10 at 18:08
  • 7
    I believe amssymb loads amsfonts. There's rarely any need to load it yourself. – TH. Sep 11 '10 at 09:13
  • 5
    Note that the ams math packages are loaded automatically if you use one of their document classes, such as amsart. – Erik P. Jan 18 '12 at 19:08
  • 19
    Instead of loading amsmath I usually load mathtools. It is based on amsmath and loads it automatically. Moreover it fixes some deficiencies of the amsmath package and provides additional useful commands such as \coloneqq. – Stan Aug 24 '14 at 09:53
  • Do I need it if I use kpfonts or mathpazo? – skan Nov 19 '16 at 13:10
204

I use hyperref for setting PDF metadata and to create links, both within the document and for clickable URLs. Even Elsevier has used urlbst to update their bibliography style to support URLs and DOIs; hyperref does the actual work of rendering url = and doi = BibTeX fields into clickable PDF links.

András Salamon
  • 2,145
  • 3
  • 25
  • 33
  • related question: http://tex.stackexchange.com/questions/1863/which-packages-should-be-loaded-after-hyperref-instead-of-before – matth Jun 26 '12 at 21:25
178

For citations and bibliographies, biblatex is the package of my choice. Key points:

  • biblatex includes a wide variety of built-in citation/bibliography styles (numeric, alphabetic, author-year, author-title, verbose [full in-text-citations], with numerous variants for each one). A number of custom styles have been published.

  • Modifications of the built-in or custom styles can be accomplished using LaTeX macros instead of having to resort to the BibTeX programming language.

  • biblatex offers well-nigh every feature of other bibliography-related LaTeX packages (e.g. multiple/subdivided bibliographies, sorted/compressed citations, entry sets, ibidem functionality, back references). If a feature is not included, chances are high it is on the package authors' to-do list.

  • The babel package is supported, and biblatex comes with localization files for about a dozen languages (with the list still growing).

  • Although the current version of biblatex (2.8a) still allows to use BibTeX as a database backend, by default it cooperates with Biber which supports bibliographies using Unicode. Biber (currently at version 1.8) is included in TeX Live and MiKTeX. Many features introduced since biblatex 1.1 (e.g., advanced name disambiguation, smart crossref data inheritance, configurable sorting schemes, dynamic datasource modification) are "Biber only".

lockstep
  • 250,273
152

The todonotes package is a must have in all my documents.

\usepackage{todonotes}

The package enables you to insert small notes in the text marking things to do in the document. Something like

\todo{Rewrite this answer \ldots}

At any location in the document a list of the inserted notes can be generated with the

\listoftodos 

command.

midtiby
  • 1,863
  • 12
    For multiuser comment support, and configurability with regard to the kinds of notes/themes available, the fixme package is quite nice (I use it quite regularly). – Mark Mar 25 '11 at 22:29
  • todonotes also supports colors and missing graphics. – raphink Jun 16 '11 at 10:42
  • I find todonote invaluable as I prepare syllabai and course material for the upcoming term. Because I cannot do everything at one sitting I put a todo note whenever i find something I have to wait to do. I also use it during the semester to highlight to the students anything which was changed after the documents were first published. – R. Schumacher May 01 '12 at 20:51
  • 5
    Personally I use an editor which automatically highlights and groups in the "structure" window any comment that begins with %TODO: Works better for me because you don't have anything in your compiled document giving away the fact that it still has TODOs around. – Heather Jun 12 '13 at 10:53
  • 15
    Has anyone done a comparison between easy-todo, fixme, fixmetodonotes, todo, and todonotes? – Ari Brodsky Nov 20 '13 at 01:12
  • 1
    For me, the nicest part of todonotes is that when I am done, I can remove the usepackage, and if I have forgotten something, LaTeX will scream loudly. Instead, a TODO in a comment may end up leaking – Davidmh Aug 15 '19 at 11:49
144

One package that’s really general purpose is nag: It doesn’t do anything, per se, it just warns when you accidentally use deprecated LaTeX constructs from l2tabu (English / French / German / Italian / Spanish documentation).

From the documentation:

Old habits die hard. All the same, there are commands, classes and packages which are outdated and superseded. nag provides routines to warn the user about the use of those. As an example, we provide an extension that detects many of the “sins” described in l2tabu.

Therefore, I now always have the following in my header (before the \documentclass, thanks qbi):

\RequirePackage[l2tabu, orthodox]{nag}

It’s a bit like having use strict; in Perl: a useful best practice.

Bernard
  • 271,350
Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160
  • 24
    Somewhat better is \RequirePackage[l2tabu,orthodox]{nag} before \documentclass. The package docu also recommends this. – qbi Jul 29 '10 at 18:40
  • 6
    This package sounds useful. However, when I tested it with a large project, I started to get the message "Label(s) may have changed. Rerun to get cross-references right." no matter how many times I re-run Latex. – Jukka Suomela Jul 31 '10 at 09:36
  • Your description sure sounds like a package that's really specific, not really general purpose …. – LSpice Jan 10 '19 at 02:33
  • @LSpice How so? It’s very general purpose in that it can/should be included into every LaTeX document, rather than only specific types of documents. It’s certainly specific in that it does one specific thing (diagnostics), but by that definition every package is specific rather than general-purpose. Clearly not what most people would think about. – Konrad Rudolph Jan 10 '19 at 10:03
  • Well, probably my making even one comment, and certainly my making two, was my going beyond usefulness; but to me you are describing something that's widely useful, not something that's general purpose. Something that's general purpose can, I think, be used to do many things (think of the amsmath package, which adds a lot of goodies to all kinds of math environments); something that does one thing isn't general purpose, even if it does that one thing in many circumstances. (I wouldn't call a watch 'general purpose', for example, even back when people wore them all the time.) – LSpice Jan 10 '19 at 13:05
129

I nearly always use the tikz package. Once you learn how to draw with it, you can do almost any vector graphic you need.

fabikw
  • 6,203
  • I have always used Inkscape for the production of my vector images, diagrams and whatsoever. Does tikz produce comparable diagrams? How much effort is involved? – levesque Nov 15 '10 at 18:28
  • 4
    You can produce almost any diagram with Tikz. Check the tikz examples page.

    http://www.texample.net/tikz/examples/

    However, it is fairly complicated to get the hang on large diagrams since you have to type everything and nearly always you can't see what you are doing. But if you are using a Debian/KDE combination, you can use Ktikz/Qtikz which is really helpful since it compiles tikz code in real time.

    – fabikw Nov 16 '10 at 00:42
  • 47
    TikZ is awesome with a capital A. But load it by default? It takes up a lot of time and space. I would say only load it if you need it. – Matthew Leingang Nov 22 '10 at 12:53
  • It takes time, but nearly always I find I need to do something with it. – fabikw Nov 23 '10 at 01:11
  • 10
    @levesque: Tikz has a fairly steep learning curve, but it is beautifully documented and provides rich libraries. I find the vector graphics that I produce in tikz to be superior to those I produced in inkscape. It seems easier on my brain to stay in keyboard mode as well. – philosodad Dec 29 '10 at 04:56
129

Another essential package combination is

\usepackage{booktabs}
\usepackage{array}

The booktabs package creates much nicer looking tables than the standard latex tables; the array package's ability to create custom columns is invaluable for formatting tabular material on a per-column basis.

Alan Munn
  • 218,180
128

I'm surprised that no one has mentioned

\usepackage[margin=1in]{geometry} % set page margins automatically 

This is in every document I write (with varying margins, of course.)

Alan Munn
  • 218,180
  • 19
    This is generally poor style. The design of the page is pretty involved and lots of thought has went into (La)TeX's default designs. If you're interested in just saving paper, consider the packages savetrees or fullpage. – Quadrescence Apr 16 '11 at 23:15
  • 29
    Both savetrees and fullpage change other things too; Anyway, the point of of the answer is that geometry is a must use package, no matter what margins you choose for it. The appropriateness of 1in margins also depends on the kind of documents you produce. – Alan Munn Apr 16 '11 at 23:38
  • 14
    It is not a must if you use a class from the KOMAscript bundle or memoir. – Sveinung Jan 13 '14 at 16:01
  • @Sveinung but it is a must if you have to comply with certain margins, because your supervisor/advisor/publisher orders you to do so. – Skillmon Dec 14 '18 at 20:08
  • @Skillmon No, because memoir and KOMA have their own ways to set margins, so geometry isn't needed, which is what Sveinung means, I suppose. – Alan Munn Dec 14 '18 at 20:10
  • @AlanMunn KOMA's approach to set the margins is by division. You can't easily set arbitrary margins with typearea, as it'll always produce certain ratios (e.g. top margin is half of bottom margin). The result is however beautiful and I'd personally never use geometry unless I have to meet other peoples' criterion. For memoir you're right though, that one is supposed to have code similar to geometry's. – Skillmon Dec 14 '18 at 20:20
  • @Skillmon Maybe so. I will never use KOMA as its English documentation is abysmal. – Alan Munn Dec 14 '18 at 20:23
  • @AlanMunn don't know, I always read the German one, and that one is pretty nice :) – Skillmon Dec 14 '18 at 20:25
  • 1
    @AlanMunn And the English one is good enough for a Norwegian :) – Sveinung Dec 16 '18 at 18:34
  • 1
    @AlanMunn The KOMA-Script English documentation was completely rewritten last year, and is now quite readable. – Andrew Dunning Mar 14 '19 at 17:13
124
\usepackage{siunitx}

siunitx, for typesetting units and especially for the "S" column type, which allows numbers in tables to be easily aligned, e.g. on the decimal marker.

Jake
  • 232,450
  • 15
    \usepackage[allowlitunits]{siunitx} is my normal incantation, it allows you to use things like 20\milli\meter directly in math mode. – Alex Hirzel May 01 '12 at 20:18
  • I have evidently never followed through on my plan to read the siunitx manual in depth. I was not aware of the S column type or allowlitunits, thank you! – owjburnham Jul 18 '17 at 09:50
123

Since my files nowadays has UTF-8 character encoding, I use this

\usepackage[utf8]{inputenc}
Johan
  • 2,204
88
\usepackage{graphicx}

For including figures, rotating or scaling text. I also use the \graphicspath command to specify a subfolder to help organize my figures and so I can easily change between, for example, a set of figures for internal used (with extra info) and final versions for distribution.

mforbes
  • 5,571
84

The 'rich' document classes such as memoir and KOMA-Script include a lot of functionality that is not available from the LaTeX kernel. So the packages you load when using the article class might be rather different from those when using memoir. A lot of packages that get used by many people with the base classes (things like float, caption, tocbibind and titlesec) are covered by the richer document classes.

vanden
  • 30,891
  • 23
  • 67
  • 87
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 21
    \begin{gripe} My problems with these richer document classes are that it makes it very difficult to pick and choose, and that it is a major pain when Big Shot Journal says "please rewrite your document to use our class file" (there's even a journal that won't let you send an accompanying style file). \end{gripe} – Andrew Stacey Jul 29 '10 at 13:19
  • 13
    I tend to stick to article + packages, myself, so I can sympathise. All the more reason for me to get on and get LaTeX3 finished, so we can have a good set of abilities out of the box! – Joseph Wright Jul 29 '10 at 14:33
  • 12
    \begin{joke} Then stop wasting time here and get on with it! \end{joke} – Andrew Stacey Jul 29 '10 at 18:11
  • 3
    If only it were that easy :-) If you want to see that things are happening, there is an RSS feed for SVN checkins: http://www.latex-project.org/latex3svn.rss – Joseph Wright Jul 29 '10 at 21:36
  • 15
    That gripe seems a gripe with the journals, rather than with the rich document classes. Also, if you're writing a journal article, memoir doesn't seem like an obvious way to go, if you are going to end up having to conform to some journal's style eventually. Again, that's not an issue with rich document classes, that's just a matter of picking the right tool for the job. And for journal submissions, minimal package requirements and basic document classes seems a good modus operandi – Seamus Aug 01 '10 at 10:41
  • @JosephWright: even if you finished LaTeX3 tomorrow, how long would it take most journals to convert?.. – naught101 Sep 14 '12 at 06:57
  • 2
    @naught101 There is no guarantee that they ever will: it's a question of having 'killer features'. Based on the LaTeX2e experience (moving from 2.09) you are talking at least ten years. – Joseph Wright Sep 14 '12 at 07:13
  • 1
    \newenvironment{letsuseunnecessesarymarkupinourbitchycomments{\begin{letsuseunnecessesarymarkupinourbitchycomments}}{\end{letsuseunnecessesarymarkupinourbitchycomments}} – Nicholas Hamilton Apr 16 '13 at 03:20
69

In addition to many packages already listed here, I always include mathtools. It provides implementations of \mathclap (and similar commands) as well as nice extensible arrow.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • 7
    \mathclap is great. I use it to great effect for things like \sum_{\mathclap{big long thing}}. (It's also amusingly named with at least one off-color meaning.) – TH. Aug 27 '10 at 09:36
  • 4
    \shortintertext is also provided by the \mathtools package and provids tighter vertical spacing compared to \intertext from the amsmath package. – Peter Grill May 02 '12 at 00:47
65
\usepackage{lmodern}  % better i18n Postscript version of Knuth's cm fonts
SamB
  • 2,837
towolf
  • 431
64

I can't live without listings --- pretty-printing (colours, formatting and all) algorithms and code is indispensable --- in pretty much any programming languages and dialects under the sun. Plus, I can import a source file directly from the repository, and the latest version will be automatically rendered.

63

For papers on the arXiv (maths, physics and computer science mostly) there's a list of packages sorted by frequency of use.

The top twenty packages are:

  1. article
  2. graphicx
  3. amssymb
  4. amsmath
  5. revtex
  6. revtex4
  7. epsfig
  8. amsfonts
  9. bm
  10. latexsym
  11. amsart
  12. dcolumn
  13. amsthm
  14. graphics
  15. aastex
  16. amscd
  17. epsf
  18. color
  19. aa
  20. times
doncherry
  • 54,637
61

The package xspace lets you define commands that don't eat up whitespace after them. So you can define an abbreviation like

\newcommand{\sA}{\mathcal{A}\xspace}

and then you can type objects of \sA are called widgets instead of objects of \sA\ are called widgets.

Mike Shulman
  • 1,557
  • 1
    That's one I use so much that I forget it's not part of the main code! – Andrew Stacey Aug 05 '10 at 07:10
  • 22
    On comp.text.tex there's a series of messages "xspace and italic correction" about spacing inconsistencies created by xspace. There, Will Robertson suggested "delimited macros" as an alternative to xspace. Using \newcommand* only to ensure that no existing command is overriden, the above example would look like this:

    \newcommand*{\sA}{}\def\sA/{\mathcal{A}}

    To quote Will Robertson: "In the source you must always type "\foo/" [here: "\sA/"] (or TeX will throw an error), and spaces after it won't be gobbled."

    – lockstep Aug 06 '10 at 15:04
  • 1
    For me, having to write \sA/ every time would be even worse than having to write \sA\ every time. The only advantage I can see to \sA/ is that you wouldn't have to remember to delete the ending backslash when it's followed by punctuation. – Mike Shulman Aug 10 '10 at 04:14
  • 8
    The main advantage of \sa/ is that an error message will occur if you happen to forget the closing slash. On the contrary, if you happen to forget the closing backslash of \sA\, you'll end with gobbled space without noticing it. – lockstep Aug 11 '10 at 20:50
  • 6
    I used xspace one time in a paper with other authors. It was a huge pain since some macros didn't behave like others. It led to all sort of confusion, especially when thinks like \foo bar no long work as you expect because \foo's definition ends with \xspace. I've never tried \foo/. The main advantage I see with that is if your macro is \m/... – TH. Aug 27 '10 at 09:32
  • 9
    I don't especially like the look of \sA/ but I can't think of a better delimiter to use. Perhaps a semicolon would be fine (after HTML): \sA;. My personal belief is that non-delimited macros without arguments (i.e., the ones that gobble spaces) are just plain wrong for document commands because of the spacing problems. Even experienced LaTeX authors trip up with them. – Will Robertson Sep 02 '10 at 09:28
  • To be consistent, I just always type \sA{}. – inavda Jul 06 '23 at 19:49
52

First line of the document should be

\RequirePackage{fixltx2e}
\documentclass{...}

, which fixes a few things in the LaTeX2e kernel.

Due to LaTeX's stability policy, these corrections have not been incorporated into the LaTeX2e kernel, but this package does things most people would agree are bugfixes. So to load this package is always recommended for newly created documents. The corrections have no commonalities, but the package's description has a nice summary:

  • ensure one-column floats don't get ahead of two-column floats;
  • correct page headers in twocolumn documents;
  • stop spaces disappearing in moving arguments;
  • allowing \fnsymbol to use text symbols;
  • allow the first word after a float to hyphenate;
  • \emph can produce caps/small caps text;
  • bugs in \setlength and flushbottom.

EDIT 27.01.2016:

This package is obsolete for LaTeX releases after 2015. See latexrelease.pdf.

  • 1
    It should be RequirePackage{fixltx2e} as first line of you'require document, even before the document class, see http://www.texdev.net/2014/12/28/fixing-latex2e/ – MaxNoe Jan 17 '15 at 13:51
  • 1
    really should be an argument to documentclass. – ivo Welch Jan 02 '16 at 16:58
  • 10
    fixltx2e is not required with releases after 2015(fixltx2e) All fixes are now in the LaTeX kernel. – kaka Apr 03 '16 at 11:23
45

I use url to typeset urls.

Seamus
  • 73,242
Akhil Mathew
  • 295
  • 3
  • 10
34
\usepackage[parfill]{parskip} 

I much prefer no indentation and space between paragraphs, so the parskip package is a must for me!

Vivi
  • 26,953
  • 31
  • 77
  • 79
  • 18
    Have a look at the KOMA-Script-classes - they include a parskip option that is more powerful than the package of the same name. – lockstep Aug 08 '10 at 17:39
  • 4
    @lockstep, but if parskip is all you want, surely loading all of KOMA-Script is overkill for that …. – LSpice Jan 10 '19 at 02:35
34

For quickly setting multicolumn text in a single column document, the multicol package is another package that I use all the time.

\usepackage{multicol}
doncherry
  • 54,637
Alan Munn
  • 218,180
32

I almost always use the enumitem package, which makes it much easier to make modifications to lists (especially enumerate lists). Most notably, changing the labels to something like (i), (ii), (iii) [no period] with this package is as easy as

\begin{enumerate}[label=(\roman*)]
    \item The first item
    \item The second item
\end{enumerate}

Furthermore, the code above will automatically get nesting right. Before I started using this package, my preamble always included the awkward macro (necessary to change the references and eliminate the extra period in the list itself)

\newcommand{\setenumroman}{%
    \renewcommand{\theenumi}{(\roman{enumi})}%
    \renewcommand{\labelenumi}{\theenumi}%
}

which would break if I ever used it for a nested list (all the enumis would have to be changed to enumiis, if I understand correctly).

The enumitem package is quite flexible; another option I sometimes use is [wide], which makes a list look like part of the body of the text (with numbers/labels at the beginning of relevant paragraphs).

  • 1
    If someone only want the feature of changing labels, easier will be to use the enumerate package. Then you could simply write \begin{enumerate}[(i)]. But enumitem package gives a lot more flexibility including allowing the items to appear in a line. – Cyriac Antony Dec 21 '18 at 08:38
  • With the [shortlabels] option, enumitem allows the same shorter syntax as the enumerate package that was mentioned in the above comment. So you can write \begin{enumerate}[(i)] as well. – Disenchanted Lurker Jan 10 '20 at 10:43
28

To use the palatino font (it's just a nice looking font)

\usepackage[sc]{mathpazo}

Note that the old palatino package is deprecated.

Juan A. Navarro
  • 62,139
  • 32
  • 140
  • 169
Johan
  • 2,204
28

Nothing surprising here: I use natbib, hyperref and hypernat together.

Natbib for referencing.

Hyperref adds bookmarks for sections and lists and turns references and urls into links.

Hypernat allows natbib and hyperref to work together. -- Note (added 2015/02/11): natbib and hyperref have been working together just fine for at least ten years. hypernat is no longer needed for any TeX distribution with a vintage more recent than ca 2002.

Mico
  • 506,678
Vivi
  • 26,953
  • 31
  • 77
  • 79
  • 8
    I'm pretty sure that hypernat is superfluous these days. With only loading natbib and hyperref I get references as [1-5] with both 1 and 5 being hyperlinks. – Lev Bishop Aug 08 '10 at 14:51
  • Agreed, I didn't even know about hypernat until I saw this answer. I have been using hyperref and natbib for a while and reference links and backlinks always worked for me. Is there some extra functionality that hypernat adds? – Sharpie Aug 09 '10 at 17:31
  • I had a problem once, found out about natbib, and have been using it ever since, so it is possible it is superfluous and I didn't even know. I will have to test it out and get back to you guys if I find something. – Vivi Aug 10 '10 at 20:18
  • 2
    And? Was it superfluous in 2010? Is it now? ;) – K.-Michael Aye Nov 23 '12 at 05:18
  • 1
    @K.-MichaelAye - hypernat was superfluous (and potentially troublesome) back in 2010 and in 2012, and it continues to be superfluous as of 2015. – Mico Feb 11 '15 at 21:13
28

I almost always find myself using a tabularx environment as opposed to the regular tabular environment, as it allows for greater dynamism in column widths.

ESultanik
  • 4,410
26

To make sure you have ISO formated dates (YYYY-MM-DD).

\usepackage[english]{isodate}

or

\usepackage{datetime}
\renewcommand{\dateseparator}{-}
\newcommand{\todayiso}{\the\year \dateseparator \twodigit\month \dateseparator \twodigit\day}
Johan
  • 2,204
23

Another package I use is float. It allows for the placement H for floats, which is somewhat equivalent to h!, but a bit stronger, making sure the figure or table goes exactly where I want it to be.

doncherry
  • 54,637
Vivi
  • 26,953
  • 31
  • 77
  • 79
  • 7
    Actually not equivalent to h! at all. h! floats still "float"- they can be moved around by LaTeX in an attempt to optimize the document layout. Figures using the H specifier are not floats at all, they are treated like one big character and are put exactly where they appear in the text. – Sharpie Aug 01 '10 at 03:59
  • @Sharpie: you are ignoring the word "somewhat" :P Still, your point is valid, thanks! – Vivi Aug 01 '10 at 04:21
  • 1
    I did consider the word somewhat. However, in my opinion the only similarity between the two is the fact that they are used as float specifiers. Beyond that, both specifiers produce completely different effects. – Sharpie Aug 01 '10 at 06:14
  • @Sharpie: maybe I should link to the source of the (mis)information? http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Figures (see the last row of the table) – Vivi Aug 01 '10 at 06:32
  • @Vivi I fixed that entry of the wikibook. – Skillmon Dec 15 '18 at 10:46
21

For mathematical texts I instead use amsmath & Co. One very useful package is onlyamsmath. I load it as

\usepackage[all,warning]{onlyamsmath}

So it looks for $$..$$, eqnarray and produces a warning if some of them are used. If you left out warning, it will result in an error and compile will stop. This package is normally very useful if you edit a text with many authors.

qbi
  • 2,070
20

Edited by doncherry: Removed packages mentioned in separate answers.

The complete header Part of my header for most of my documents looks as follows:

\documentclass[ngerman,draft,parskip=half*,twoside]{scrreprt}
\usepackage{ifthen}

For some things I need if-then-constructs. This package provides an easy way to realise it.

\usepackage{index}

For generating an index.

\usepackage{xcolor}

xcolor is needed by several packages. For some historical reason I load it manually.

\usepackage{babel}
\usepackage{nicefrac}

nicefrac allows typesetting fractions like 1/2. It is sometimes more readable than \frac.

\usepackage[T1]{fontenc}
\usepackage[intlimits,leqno]{amsmath}
\usepackage[all,warning]{onlyamsmath}

This package warns if non-amsmath-environments are used.

\usepackage{amssymb}
\usepackage{fixmath}

Provides ISO conform greek letters.

\usepackage[euro]{isonums}

Defines comma as decimal delimiter.

\usepackage[amsmath,thmmarks,hyperref]{ntheorem}

for Theorems, definitions and stuff.

\usepackage{paralist}

Improves enumerate and itemize. Also provides some compact environments.

\usepackage{svn}

I work with VCS and svn displays some informations (keywords) from SVN.

\usepackage{ellipsis}

corrects \dots

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

These are the definitions for absolute value and norm.

\SVN $LastChangedRevision$
\SVN $LastChangedDate$
qbi
  • 2,070
19

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).

Juan A. Navarro
  • 62,139
  • 32
  • 140
  • 169
17

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.

Serge
  • 1,357
  • 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. – Konrad Rudolph Sep 11 '10 at 08:14
  • 6
    I simply use \newcommand{\comment}[1]{}. Put \comment{ before the block and } after to comment out any part of the file. – András Salamon Sep 11 '10 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 Jul 01 '13 at 02:58
17

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.

Jonas Stein
  • 8,909
qbi
  • 2,070
15

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.

FvD
  • 688
  • Could you tell us about its advantages compared to lstlisting which seems to be the most commonly used syntax highlighting package? – Christian Jun 27 '13 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: http://tex.stackexchange.com/questions/102596/minted-vs-texments-vs-verbments,

    – FvD Jun 28 '13 at 13:17
14
\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

nnunes
  • 2,944
  • 1
  • 23
  • 36
13

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.

Scott H.
  • 11,047
  • 10
    So, what does it do? – fifaltra Dec 24 '13 at 00: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 May 07 '14 at 10:17
  • Somebody else has also posted this later on (but with more/different detail) as https://tex.stackexchange.com/a/238482/78134 – owjburnham Jul 18 '17 at 15:08
13

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}
vanden
  • 30,891
  • 23
  • 67
  • 87
qbi
  • 2,070
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
doncherry
  • 54,637
José Figueroa-O'Farrill
  • 4,125
  • 2
  • 27
  • 35
  • 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? – Juan A. Navarro Jul 29 '10 at 10:51
  • 1
    can you please add comments like \ usepackage{foo} % to get following features within your code? – Dima Jul 29 '10 at 11:06
  • Sorry -- misread the format of the question. I'll break my answer up later today. – José Figueroa-O'Farrill Jul 29 '10 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). – Andrew Stacey Jul 29 '10 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 May 05 '11 at 07:40
  • Do I need that combination for math or can I rely just on a single package such as kpfonts or mathpazo? – skan Nov 19 '16 at 13:12
12

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.

Roey Angel
  • 1,699
12

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.)

Carl Mummert
  • 1,974
  • 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. – Andrew Stacey Aug 04 '10 at 07:03
10

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

Roey Angel
  • 1,699
9
\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".

doncherry
  • 54,637
9
\usepackage[scaled=0.8]{luximono} 

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

Ben
  • 2,609
7

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

Rud Faden
  • 2,124
  • 1
  • 17
  • 11
7

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

AndréC
  • 24,137
6

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.

MattAllegro
  • 1,546
6

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.

Matthias
  • 1,956
5
 \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).

Ben
  • 2,609
5

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.

Ruben
  • 13,448
N Nik
  • 3,669
4

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.

Fran
  • 80,769
4

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

4

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 ;)

sebastian
  • 859
3

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.

doncherry
  • 54,637
Matt
  • 31
3

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.

Werner
  • 603,163
SLx64
  • 2,823
3
\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).

Ruben
  • 13,448
mforbes
  • 5,571
3

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
Stefan
  • 173
  • 2
    The physics package is not very popular, cf. https://tex.stackexchange.com/q/471532/ and https://tex.stackexchange.com/q/471563/ for example – cgnieder Jan 10 '21 at 13:46
3

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}
3

I always load the package xy to produce diagrams.

Also tikz to draw figures.

Sigur
  • 37,330
2

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.

Guido
  • 30,740
  • 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 May 07 '14 at 10:24
2

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

1

The ctable package is great for typesetting beautiful tables in academic documents. Makes it much simpler and consistent, and the support for marks is awesome.

Pau
  • 189
0

I have a whole slew of commands that that provide a nice short hand for standard idioms of mine. (and which if I ever share tex source would make someone grumpy if i made it a package)

So the meta habit is: whatever personal short hands you think would be nice, have them defined at the top of your template file!

0

I always end up loading the same packages, some of which were suggested by some answers to this question, such as hyperref, amsmath, nag, etoolbox, xparse, and others.

I created a style file latexdev.sty that I use in almost all my notes and publications, which loads all these standard packages:

https://github.com/olivierverdier/latexdev

Olivier
  • 3,151
0

The epstopdf provides ability to include the EPS file so that to con­verts an EPS file to an en­cap­su­lated PDF file. The re­sult­ing file suit­able for in­clu­sion by pdfTeX as an im­age. The script is adapted to run both on Win­dows and on Unix-alike sys­tems.

0

[utf8x]{inputenc}, [T1]{fontenc} and babel are in all documents. hyperref, biblatex, graphicx and xspace and the ams family are those I rememnber from the top of my head to be in most documents.