Hacker News new | past | comments | ask | show | jobs | submit login
Essential LaTeX packages (howtotex.com)
126 points by czam on June 11, 2014 | hide | past | favorite | 48 comments



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.


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.


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.


There is nothing wrong, except I feel I shouldn't have to remember to make sure I do a \<space> after commands instead of just a space. Why should I have to remember where to put <space> and where to put \<space>, that's what computers are for!


I've been having this problem for months now and I never figured out a way around it. Thank you so much for this!


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) 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) for syntax highlighting.


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


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


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


Hell, in most of my documents I'm hard-pressed to find a use for more than 5 packages, let alone 50. My résumé isn't using any packages at all right now; it's just using vanilla LaTeX, since I think that looks nice enough and it's easy enough to manage.


Another advantage of vanilla LaTeX is as a litmus test: if your interviewer recognizes Computer Modern, you know they're legit.


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.


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


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.


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.


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.


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.


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.


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

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


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.


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


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


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.


That's a fair assessment. I drank the LaTeX koolaid >15 years ago when I didn't even have a clearly compelling reason to do so. Now back in school working on a PhD, and wondering why anyone wouldn't use it. How quickly we forget our learning pains.


You can use latex as mostly a markup language. Put in your default header and write your document with sections and so on.

I usually try to not worry about fine-tuning at all until the document is done, otherwise the whole point of latex is lost to me.


I seem to remember inskcape has a pstricks export. Searching on google also turns up this for svg to tikz conversion:

https://github.com/kjellmf/svg2tikz


Dia has an option to flawlessly export output as LaTeX PGF macros and TeX PSTricks macros--I LOVE those two features. In the past, I've also used LaTeX Draw.


I use geogebra's tikz or pstricks export and tweak the figure afterwards.


Agreed. TikZ is simply an awesome tool. If people want to try it out, I found A Very Minimal Introduction to TikZ by Jacques Crémer a great resource to help get started. There are also some handy examples here: http://www.texample.net/tikz/examples/

EDIT: Forgot link to Crémer's guide: http://cremeronline.com/LaTeX/minimaltikz.pdf


The manual is amazing too. Especially good is the author's sense of humor and the design primer in chapter 7. For anybody wanting to get started I would recommend taking a look at the tutorials.

http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf


For anyone that is staring at "VII: Utilities" and wondering where the design primer is, I think the above comment is referring to "Part I: Tutorials and Guidelines, Section 7: Guidelines on Graphics." The section begins on page 91 of the linked document.


+1 for tikZ. I graphically present information using R plots and R's tikzDevice package enables me to export output to native TeX. I NEED tikZ to include external R TeX exports. When it comes to vector graphics, Dia is my friend and I export output as LaTeX PGF macros...


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.


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.


I don't know what OP meant, but I've found booktabs to be essential for making attractive tables. The package manual is pretty informative: http://www.ctan.org/tex-archive/macros/latex/contrib/booktab...


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.


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


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.


Academic here: sharelatex went down before a major conference deadline a few months back. I just use `git` and `make` for my latex workflow, but I learned several colleagues down the hall use sharelatex when they all shouted simultaneously :) (everything worked out OK for them though)


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


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


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.


Privacy and self determination.


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!


Self Plug

I wrote about Syntax highlighting in LaTeX

https://sites.google.com/site/jestinjoy/academic/latex/highl...



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


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




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: