The babel
package loads the (last) language at begin document, thanks to an \AtBeginDocument
command (lines 12.256 and 12.257 of its kernel):
\AtBeginDocument{%
\expandafter\selectlanguage\expandafter{\bbl@main@language}}
On the other hand, the \AfterEndPreamble
command from the etoolbox
package is supposed to execute "code [...] at the very end of \begin{document}
, after any \AtBeginDocument
code."
But it seems not to be the case in the following MCE:
\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{babel}
%
\AfterEndPreamble{%
\title{Quelle crise?}%
}
%
\begin{document}
\maketitle
\end{document}
Indeed, if executed after the french language would be loaded, \title{Quelle crise?}
should give a thin space before the "?" as it is the case in the following MCE:
\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{babel}
\begin{document}
\title{Quelle crise?}
\maketitle
\end{document}
\begin{document}
when\AfterEndPreamble
is used. The command you have in mind is probably\AtEndPreamble
.