Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

Addendum

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}}
\renewcommand*{\newunitpunct}{\addcomma\space}
\bibliography{biblio}
\title{}
\author{}
\usepackage[francais,english]{babel}
\usepackage{csquotes}
\usepackage[colorlinks]{hyperref}
\begin{document}
\maketitle
\tableofcontents
\onehalfspacing


\printbibliography
\end{document}

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

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

share|improve this question
6  
I usually place it early in the preamble, so other packages can pickup its settings. –  Andrew Swann Dec 20 '13 at 13:07
3  
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

1 Answer 1

up vote 13 down vote accepted

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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