76

This isn't a real question, so I'm marking it community wiki.

When I was new to LaTeX, I thought that the \usepackage command worked much like the #include command of the C language: just put whatever you need in the preamble, in whatever order you like.

But then bugs began to bite me and I realised, with growing horror, that commutative packages seem to be the exception rather than the rule.

They appear so often that I think it would be useful to have a list here of problematic interactions between pairs of packages, and their correct order.

Also, a question for amusement:

I want to know if there exists three packages A, B and C, such that A has to be included before B and B needs to be included before C, but C needs to be included before A.

8
  • 1
    Is that last sentence a question if three such packages exist?
    – TH.
    Sep 15, 2010 at 3:59
  • 1
    Note that C isn't immune to non-commutative inclusions: #include just literally pastes in the relevant source code file at that point before compilation. C header file writers tend to be better at not messing with each other, and C more tolerant for changing definitions. Sep 15, 2010 at 4:51
  • 2
    \usepackage does work like the #include directive, and if you could overwrite existing definitions in C, you'd run into the same issues that LaTeX has.
    – Philipp
    Sep 15, 2010 at 9:42
  • 4
    At least in theory, you could have just two packages that don't "play nice": If both package foo and package bar both redefine two commands, \jedi and \sith, and you want foo's \jedi but bar's \sith, then no order of package loading will get you both...
    – Seamus
    Sep 15, 2010 at 10:51
  • 8
    As much as I like using math terminology for non-math situations, this question seemed to be a bit hard to find for non-math people. I changed the title to something more directly descriptive.
    – Caramdir
    Oct 24, 2010 at 23:24

3 Answers 3

37

Freek Dijkstra has put together a nice wiki of Latex package conflicts. Hyperref is the one he singles out for criticism: it has the nasty property that sometimes it conflicts when it is put earlier, sometimes when it is put later than other widely used packages, encouraging cargo-cult document headers.

He's had less trouble with inputenc conflicts that others, judging from complaints that I've seen, mostly, I guess, because he uses Xetex.

3
  • 3
    Of course you have less trouble with inputenc in XeLaTeX, simply because you never load inputenc.
    – Philipp
    Sep 15, 2010 at 9:43
  • 10
    Regarding hyperref: it's not the hyperref package that is to be criticized, but rather the LaTeX2e kernel, which seems to combine every possible software development antipattern in a single package.
    – Philipp
    Sep 15, 2010 at 9:44
  • @Philipp - You might load inputenc if you run xelatex on a document written by someone else who is using Pdftex. Nov 24, 2015 at 14:25
2
mathtools

needs to go before

mathabx
4
  • 1
    but mathabx changes essentially every single symbol, so be very sure you really want to do that before using it. there are ways to load just a few symbols from those fonts; see Importing a Single Symbol From a Different Font. Jan 22, 2016 at 20:01
  • Huh, okay I didn't know that. I posted a question about it but it got closed saying it was a duplicate of this question. Result: I still don't know anything.
    – j0equ1nn
    Jan 22, 2016 at 20:25
  • i posted a rather substantial comment on the closed question. i think you might find that helpful. (of course, i'm biased. on the other hand, i have >30 years of experience with tex, so that should count for something.) if what you're working on is a thesis, take a look at nicola talbot's (excellent!) book, Using LaTeX to Write a PhD Thesis. Jan 22, 2016 at 20:38
  • Okay, thx a lot. Too bad it couldn't have been an answer though, sometimes the comments slip through the cracks.
    – j0equ1nn
    Jan 22, 2016 at 20:40
0

titlesec has to be loaded before beamerarticle as described here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.