
Essential LaTeX packages - czam
http://www.howtotex.com/packages/9-essential-latex-packages-everyone-should-use/
======
CJefferson
I would recommend everyone look at xspace.

It only has one tiny aim - to deal with spaces after commands.

Given: \newcommand{\S}{Bob} then \S is \S. expands to:

    
    
        Bobis Bob.
    

While: Given: \newcommand{\S}{Bob } expands to

    
    
        Bob is Bob .
    

One can write: \newcommand{\prog}{\textsc{prog}\xspace}. Then we get:

    
    
        Bob is Bob.

~~~
symmetricsaurus
Is there anything wrong with the simple approach of just adding \<space> after
the command? For example: \newcommand{\T}{Mike} \T\ is \T. Which will give
you: Mike is Mike.

~~~
dfc
The problem with hard coding the space is there are times it is not
wanted/needed. I am stealing the following from xpsace documentation.

Input with "\newcommand{\gb}{Great Britain\xspace}":

    
    
      \gb is a very nice place to live.\\
      \gb, a small island off the coast of France.\\
      \gb\footnote{The small island off the coast of France.} 
      is a very nice place to live.
    

Results in the output

    
    
      Great Britain is a very nice place to live.
      Great Britain, a small island o the coast of France.
      Great Britain[^1] is a very nice place to live.

------
edwintorok
As mentioned in the comments there are some language/font settings that are
essential:

    
    
      \usepackage[english]{babel}
      \usepackage[utf8]{inputenc}
      \usepackage[T1]{fontenc}
    

Then alongside microtype the package upquote is useful too (for correct quotes
inside verbatim):

    
    
      \usepackage{upquote}
    

If you want to include source code then listings is nice:

    
    
      \usepackage{listings}
    

Also when creating PDF I always check with pdffonts that all the fonts really
are Type1. It can happen that you don't have a package installed (such as cm-
super), and if you use the default fonts you may end up with a bitmap font
embedded.

~~~
dfc
For anyone new coming to latex instead of messing with unicode bandaids and
worrying about fonts they can just use xelatex/lualatex and fontspec.

~~~
contingencies
Yes. I use LyX and XeTeX for a book I am writing that features at least five
or ten different non-western script based languages (Chinese, Sanskrit, Tai,
etc.) It's a pain to set up but works very well once you get going. Nothing
else worked.

------
peatmoss
My two packages that get used pretty much all the time are biblatex(-chicago)
and memoir. Memoir is my friend because it includes so much of the
functionality that is otherwise spread across a bazillion packages, _and_
makes sure it all works nicely together.

~~~
edwintorok
I'm using KOMA-Script (scrbook, etc.), although I looked at Memoir at some
point. Both have very detailed documentation, and I don't have strong reasons
for choosing one over the other.

~~~
dfc
I have a sense that the coin toss between KOMA and memoir often comes down to
which direction, east or west, provides the shortest route to the Atlantic
Ocean.

------
gradschool
The OP also should have included latexmk in the list, which is a build system
that runs latex and auxiliary programs such as bibtex sufficiently many times
to build a document with correct cross references. It can be configured to
rebuild a document whenever any source file changes and refresh a viewer such
as evince or xpdf, so you only have to save the .tex file in your editor to
see the updated typeset version. I've used LaTeX for years and only discovered
latexmk recently, but it has made the workflow much more pleasant.

I've always wished it were easier to define new environments with arbitrary
syntax that gets passed to external programs for conversion to LaTeX code
while LaTeX is running. A package called dot2texi has that ability for dot
code snippets (i.e., AT&T graph visualization tools, dot etc.), and the
dot2texi source code shows how to do it in general.

I agree with the comments that Tikz is an amazing package, and I didn't
realize until recently that it includes many state of the art graph layout
algorithms that are as good or better than dot, with highly customizable
features such as allowing the user to specify absolute positions of some of
the nodes and letting the algorithm place the rest. It seems the whole section
of the Tikz manual pertaining to automated graph drawing is omitted if it's
built on a system that doesn't have LuaTeX installed, which is how I must have
missed it.

~~~
jarvist
A lighter weight approach to latexmk I've recently found is via a Makefile:
[https://github.com/ransford/pdflatex-
makefile](https://github.com/ransford/pdflatex-makefile)

There's issues - for instance figure updates don't cause a recompile.

------
x3ro
At some point I started writing my own templates rather than packages. There
are LaTeX packages for almost everything imaginable, but it's always been
annoying to get a new document up quickly.

So now I have my template repository
([https://github.com/x3ro/x3-latex](https://github.com/x3ro/x3-latex)) which
has a very basic init script, which I call like this:

x3-init x3-paper some/folder/

And it creates a complete skeleton for the document, including a tiny build
script that transforms the main text body written in markdown to LaTeX
(because who really wants to write LaTeX lists and stuff, right?).

My point is that I find such a list of "essential LaTeX packages" quite
pointless, especially if it's only ten or so of them. It's like writing a post
on the "10 best parts of a motorcycle" or something. There are thousands of
awesome packages out there, and creating a repertoire and putting everything
together takes time. I'd welcome it if somebody came up with a really nice
template repository style thing for LaTeX, though.

PS: My favorite LaTeX package is definitely minted
([http://stackoverflow.com/a/1985330/124257](http://stackoverflow.com/a/1985330/124257))
for syntax highlighting.

~~~
dfc

      > There are thousands of awesome packages out there
    

Statements like this are terrible for latex adoption and with all due respect
an exaggeration bordering on bullshit. "OMG, I need to learn about thousands
of packages to write my paper? Screw that I am using LibreOffice or Word."

I doubt you can come up with a list of 2,000 awesome packages. It looks like
CTAN has 1500 packages and a lot of those are obsolete, redundant and/or just
plain "not awesome." More importantly I would be willing to bet that the
overwhelming majority of users can get by with less than 50 packages. A quick
grep of you x3-paper repo and it seems that all of your use cases combined
also fall under the 50 packages mark. A new user can get started and produce
quality documents with far less than 50 packages.

~~~
x3ro
"With all due respect" _sigh_

I might have gone overboard with "thousands of _awesome_ packages", but the
CTAN I'm looking at lists 4706 packages from around 2000 authors. I'm not sure
how you determined that most of these are redundant and/or obsolete. At least
MacTex seems to ship with quite a lot of them (2.3G with 600M optionals).

> I would be willing to bet that the overwhelming majority of users can get by
> with less than 50 packages.

When did I claim that this is not the case? Less then 50 packages yes, but not
the same packages for all users.. Many packages for many different use-cases.

> Statements like this are terrible for latex adoption

Yeah sure, because the people here at HN will think "Oh no if there are
thousands of packages I will need to learn _all of them_ before writing my
first document.

I'd say that what's terrible for LaTeX adoption is that it's terrible annoying
to write...

~~~
dfc
Why "sigh" at a remark that was written in order to be polite and yet still
convey strong disagreement?

------
ecesena
Since "top 10" is better than "top 9", I'd add TikZ. Ok, you need it only if
you need to draw pictures, but it's an incredible tool.

~~~
peatmoss
"I just need a quick conceptual diagram for my paper." ...10 hours elapse.

I love that TikZ lets you embed graphics right in your document without
external dependencies on PDF figures, but I've never been able to build
anything non-trivial without quite a lot of effort.

If the OmniGraffle people are listening, I've been buying your product every
release since I think about 2003 or 2004. I would love to see clean,
approximate TiKZ export (where possible with simple geometries) with janky,
verbose PGF as a fallback option when an exact complicated reproduction is
required.

~~~
ecesena
"I just need a quick 1 page report of my work." ...10 hours elapse using LaTeX
rather than word. :)

TikZ is not different that LaTeX in general. It has a hard learning curve, but
you gain long term on reuse, structure, versioning.

Also slides in Beamer are a mess at the beginning, but maintaining/sharing/co-
working... I personally think it's way easier than with ppt.

~~~
dfc
I agree that the learning curve for tikz and latex is greater than word.
However I think it is disingenious to say that tikz and latex are no different
when it comes to the initial and/or MWE learning curve. In my opinion tikz's
learning curve is steeper. For starters there is no tikz equivalent of:

    
    
      $ nano mydoc.md ; pandoc -t latex -S -o mydoc.tex mydoc.md
    

Pandoc drastically reduces the initial learning curve for latex and beamer.

That being said tikz was one of the packages I thought was noticeably absent
from the nine listed packages. The other package that I would add was
fontspec, in fact I was shocked to see microtype and not see fontspec
mentioned next.

------
jimhefferon
What could OP mean in the booktabs section about a necessity in LaTeX's table
layout for vertical separators? The linked-to post seems to mean vertical
rules (as opposed to inter-line vertical separation), but vertical rules are
obviously not required in LaTeX tables. And, some inter-column space typically
has to be there.

~~~
peatmoss
Yeah, vertical rules aren't necessary in standard LaTeX, but I think I get
where he's coming from. Most people who grok publication-quality tables are
probably using booktabs already, and those who don't are probably overusing
vertical rules.

------
bristol
My favourite is missing from the list: \usepackage{needspace}.

LaTeX' page-breaking algorithm gets it right most of the time but sometimes a
bit of help makes it even better, i.e. a

    
    
        \needspace{4\baselineskip}
        \subsection{Something}
        Lorem ipsum ...
    

tells TeX to insert a pagebreak here if there's fewer than 4 lines of text
left on the page, otherwise just carry on. Unlike \pagebreak[n], this is not
optional.

\usepackage{refcheck} belongs in everyone's toolbox as well.

------
ryan1234567890
cleverref is great but I gave up on it after finding how often it's
incompatible with journal/conference .sty files

------
saboot
Are there any compelling reasons to not avoid latex packaging and installing
by using an online tool like sharelatex.com or writelatex.com ? They always
seem up to date on latex packages and have a wide variety. I'm admittedly a
latex-noob so I've only used it to create a few slides with beamer.

~~~
sjtrny
Version control and speed are two reasons why I prefer local editing rather
than writelatex.

~~~
saboot
Version control is a good feature. I read that sharelatex.com is working on
adding git based versioning but currently there's not much information about
it.

It seems that there isn't an online editor that currently supports versioning
through git/hg, which is too bad

~~~
sjtrny
I've spent many restless nights thinking about how to best integrate git and a
web latex editor. It's a hard thing to do as there is a clash of philosophies.
The web latex editors are about making your word processing as simple as
possible with minimum required knowledge and effort. Git on the other hand
requires a working knowledge of the Git versioning model before you can start
doing anything with it. Forcing Git upon unfamiliar users would scare them
away.

------
intull
Include "minted" and make that 10! XeLaTeX with minted is a very neat
combination.

XeLaTeX allows you to use TTF fonts in your LaTeX document and minted allows
you to syntax highlight code. For books/articles, especially by those in the
software industry, it'll certainly come in handy!

~~~
jestinjoy1
Self Plug

I wrote about Syntax highlighting in LaTeX

[https://sites.google.com/site/jestinjoy/academic/latex/highl...](https://sites.google.com/site/jestinjoy/academic/latex/highlighting-
source-code)

------
mythealias
From stackexchange: [https://tex.stackexchange.com/questions/553/what-
packages-do...](https://tex.stackexchange.com/questions/553/what-packages-do-
people-load-by-default-in-latex)

------
im3w1l
Is it possible to hire a latex monkey for converting libreoffice documents?

------
jackmaney
XY-pic is also useful for drawing graphs, commutative diagrams, etc. With
enough twisting, it could probably be used to create UML diagrams.

