# Should babel package call be placed at the end of the preamble?

I remember to have read few year ago1 that babel line2 should be placed at the end of the preamble in order to avoid problems with other packages. (I believe hyperref package should also be placed at the end of the preamble for the same reason.)

However, I see, in MWEs, the babel line often just after the \documentclass.

Is there any differences? What is the good practice here?

Here is my LaTeX template. Do you see any other misplaced packages calls in general?

\documentclass[12pt,twoside,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{todonotes}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{xspace}
\usepackage[style=authoryear-comp,hyperref,backend=biber,isbn=false,doi=false,url=false,date=year]{biblatex}
\AtEveryBibitem{\clearlist{language}}
\bibliography{biblio}
\title{}
\author{}
\usepackage[francais,english]{babel}
\usepackage{csquotes}
\begin{document}
\maketitle
\tableofcontents
\onehalfspacing

\printbibliography
\end{document}


1. I don't remember where... Sorry.

2.\usepackage[dutch,english]{babel}

-
I usually place it early in the preamble, so other packages can pickup its settings. –  Andrew Swann Dec 20 '13 at 13:07
I always put it third, after fontenc and inputenc. –  egreg Dec 20 '13 at 18:17
@egreg thanks but is there some guideline here? and if yes, what is the reasons? –  ppr Dec 30 '13 at 22:03

Some packages behave differently, or adapt themselves somehow, if babel has already been loaded or not: for instance biblatex, csquotes, datetime, fmtcount, glossaries, listings microtype, natbib, tikz, to name the most used. So it's best to load babel as soon as possible.

I tend to group package calls by category. First the ones that directly involve the main choices for my document:

\usepackage[T1]{fontenc}    % alphabets to prepare
\usepackage[utf8]{inputenc} % input encoding
\usepackage[italian]{babel} % language(s)

\usepackage{kpfonts}        % or another font package

\usepackage{geometry}       % if needed for page shape
\geometry[<options>]

\usepackage{fancyhdr}       % if needed (it should go after geometry)
<fancyhdr settings>


Then I load the other utility packages in a possibly meaningful order:

\usepackage{amsmath,amssymb,amsthm}

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{microtype}

\usepackage{csquotes}            % for biblatex, mainly
\usepackage[<options>]{biblatex} % or natbib


and so on. Of course, hyperref should be last, but cleveref should go after it, if loaded.

Note: kpfonts is just by way of example. I'm not generally tied to a particular font.

If etex becomes necessary, it should go first. Other packages to be loaded early are of course ifpdf, ifxetex and ifluatex, when needed.

Command definitions and other settings go after all packages have been loaded.

-
You can add listings to your package list that should be load after babel. See tex.stackexchange.com/questions/100717/… –  quinmars Dec 31 '13 at 0:21
@quinmars I did a rather coarse grep for \@ifpackageloaded{babel} and listings didn't show up. I'll add it, because it's very frequently loaded. –  egreg Dec 31 '13 at 0:23
I actually don't know why changing the order helps, but it seems to be related to the babel shorthands. But I don't know much about how this is handle internally. –  quinmars Dec 31 '13 at 0:35
Well the "behaves differently" is more like a works or works not for listings. –  quinmars Dec 31 '13 at 0:41
@quinmars "adapt themselves" applies. –  egreg Dec 31 '13 at 0:44