% \iffalse meta-comment
%
% This program can be distributed and/or modified under the terms
% of the LaTeX Project Public License either version 1.3c of this
% license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% Please report errors to: daniel (dot) flipo (at) free (dot) fr
%
%<*batch>
%<*gobble>
\ifx\jobname\relax\let\documentclass\undefined\fi
\ifx\documentclass\undefined
\csname fi\endcsname
%</gobble>
\input docstrip.tex
\keepsilent
\let\MetaPrefix\relax
\preamble
This is a generated file part of the babel-french bundle
to be used with the Babel system.
-------------------------------------------------------------

It may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version.
The latest version of this license is in
  http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2003/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is Daniel Flipo.

Please report errors to: <daniel (dot) flipo (at) free (dot) fr>

\endpreamble
\postamble
\endpostamble
\let\MetaPrefix\DoubleperCent
\askforoverwritefalse
\generate{\file{french.ldf}{\from{frenchb.dtx}{french}}
         }
\def\MetaPrefix{-- }
\def\luapostamble{\MetaPrefix\space End of File frenchb.lua.}
\usepostamble\luapostamble
\nopreamble
\generate{\file{frenchb.lua}{\from{frenchb.dtx}{lua}}
         }
\endbatchfile
%</batch>
%<*gobble>
\fi
\expandafter\ifx\csname @currname\endcsname\empty
\csname fi\endcsname
%</gobble>
%
%<*dtx>
\ProvidesFile{frenchb.dtx}
%</dtx>
%<french>\ProvidesLanguage{french}
%<lua>--[[
%<lua>   File `frenchb.lua’ generated from frenchb.dtx
         [2026-06-06 v4.1a French support from the babel system]
%<lua>   Copyright © 2014-2026 Daniel Flipo
%<lua>   <daniel (dot) flipo (at) free (dot) fr>
%<lua>   License LPPL: see french.ldf.
%<lua>--]]
%
%<*dtx|french>
%%
%%  Babel package for LaTeX version 2e
%%  Copyright © 1996-2026
%%            by Daniel Flipo <daniel (dot) flipo (at) free (dot) fr>
%%
%</dtx|french>
%<*dtx>
%%  This file is part of the babel system, it provides the source
%%  code for the French language definition file.
%%
%</dtx>
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}[2026/06/01]
\DocumentMetadata{pdfstandard={A-4f,UA-2}, tagging=on, lang=en-GB}
\documentclass[a4paper,british]{ltxdoc}
\usepackage[left=38mm,right=38mm,top=30mm,bottom=50mm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage[no-math]{fontspec}
\usepackage{realscripts}
\usepackage{setspace}
\setstretch{1.15}
\setmainfont{SourceSans3}[
    Scale          = 1.13 ,
    Extension      = .otf ,
    UprightFont    = *-Regular ,
    ItalicFont     = *-RegularIt ,
    BoldFont       = *-Bold ,
    BoldItalicFont = *-BoldIt ]
\setmonofont{MonaspaceNeon}[%
    Scale = MatchLowercase,   FakeStretch = .82 ,
    HyphenChar=None,
    Extension = .otf,
    UprightFont = *-Regular,
    ItalicFont = *-Italic,
    BoldFont = *-ExtraBold,
    BoldItalicFont = *-ExtraBoldItalic,
  ]
%
\usepackage{babel}
%
\def\ColorArg{\color{Sepia}}
\def\PrintMacroName#1{%
  \strut\MacroFont\ColorArg\normalsize\string#1}
\usepackage[verbose=silent]{microtype}
\usepackage{array,url}
\usepackage[numbered]{hypdoc}
\hypersetup{colorlinks,urlcolor=Blue,linkcolor=Blue}
\newcommand*{\hlabel}[1]{\phantomsection\label{#1}}
\newcommand*\babel{\texttt{Babel}}
\newcommand*\frenchb{\texttt{babel-french}}
\newcommand*\file[1]{\texttt{#1}}
\newcommand*\cls[1]{\texttt{#1}}
\newcommand*\pkg[1]{\texttt{#1}}
\newcommand*\opt[1]{\texttt{#1}}
\newcommand*\env[1]{\texttt{#1}}
\newcommand*\exe[1]{\texttt{#1}}
\newcommand*\fbo[1]{\texttt{\ColorArg #1}}
\newcommand*\fbsetup[1]{\cs{frenchsetup}\{\fbo{#1}\}}
\renewcommand\meta[1]{\textit{<#1>}}  % no math mode (see doc.sty)
\let\Module\meta                      % no math mode (see doc.sty)
\EditInstance{item}{description}{%
    label-format = \normalfont #1 ,
    label-align = left
  }
% Up to 7 levels of \begin{macro} ... \end{macro} for ltxdoc.cls
\setcounter{maxblocklevels}{8}
\DeclareInstanceCopy{block}{std-list-0}{std-list-1}
\DeclareInstanceCopy{block}{std-list-7}{std-list-6}
\DeclareInstanceCopy{block}{std-list-8}{std-list-6}
\NewCommandCopy{\up}{\textsuperscript}
\hyphenation{Lua-TeX Lua-LaTeX Xe-LaTeX}
\lefthyphenmin=2 \righthyphenmin=3
\setlength{\parindent}{0pt}
\RecordChanges
\AtEndDocument{%
   \clearpage
   \section{Change History}%
   \GlossaryPrologue{}%
   Changes listed in reverse order (latest first) since~v3.3.
   \PrintChanges
}
\begin{document}
\GetFileInfo{frenchb.dtx}
\begin{center}
  \textbf{\Large A Babel language definition file for French}\\[2mm]^^A\]
  \textbf{\large frenchb.dtx \fileversion, \filedate}\\[3mm]^^A\]
  Daniel Flipo\\
  \texttt{daniel.flipo@free.fr}
\end{center}
\vspace{2\baselineskip}
\thispagestyle{empty}
\tableofcontents
\clearpage
\DocInput{frenchb.dtx}
\end{document}
%</driver>
%<*gobble>
\fi
%</gobble>
% \fi
%
%  \section{The French language}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.}, defines all the language definition macros for the
%    French language.
%
%    Customisation for the French language is achieved following the
%    book ``Lexique des règles typographiques en usage à
%    l’Imprimerie Nationale’’ troisième édition (1994),
%    ISBN-2-11-081075-0.
%
%    First version released: 1.1 (May 1996) as part of
%    \babel-3.6beta. Version~2.0a was released in February 2007 and
%    version~3.0a in February 2014.
%
%    \vspace{\baselineskip}
%    \begin{center}
%      \fbox{\parbox{.75\textwidth}{\centering\Large\bfseries
%            This file \file{frenchb.dtx} is for LuaTeX,\\
%            See file \file{frenchb3.dtx}\\
%            for pdfTeX and XeTeX.}%
%           }
%    \end{center}
%    \vspace{\baselineskip}
%
%    \textbf{Significant changes, listed in section~\ref{ssec-changes},
%    p.~\pageref{ssec-changes}, have occurred in version 4.1a, please
%    read section~\ref{ssec-changes} if your documents have French as
%    main language.}
%
%    \vspace{\baselineskip}
%    \frenchb{} has been improved using helpful suggestions from many
%    people, mainly from Jacques André, Michel Bovani, Thierry Bouche,
%    Vincent Jalby, Denis Bitouzé, Thomas Savary, Ulrike Fisher and
%    Marcel Krüger.  Thanks to all of them!
%
%    An extensive documentation in French (file \file{frenchb-doc.pdf})
%    is now included in \frenchb.
%
%  \subsection{Basic interface}
%
%    In a multilingual document, some typographic rules are language
%    dependent, i.e.\ spaces before `high punctuation’ (|:| |;| |!|
%    |?|) in French, others modify the general layout (i.e.\ layout of
%    lists, footnotes, indentation of first paragraphs of sections) and
%    should apply to the whole document.
%
%    The French language can be loaded with \babel{} by a command like:
%    \\ |\usepackage[german,spanish,french,british]{babel}|%
%    \footnote{\emph{Always} use \opt{french} as option name for the
%    French language, former aliases \opt{frenchb}, \opt{francais} and
%    \opt{acadian} have finally been removed as announced several years
%    ago!}
%
%    \frenchb{} takes account of \babel’s \emph{main language} defined
%    as the \emph{last} option at \babel’s loading or set through the
%    |\DocumentMetadata{lang=..}| command.  When French is not
%    \babel’s main language, \frenchb{} does not alter the general
%    layout of the document (even in parts where French is the current
%    language): the layout of lists, footnotes, indentation of first
%    paragraphs of sections are not customised by \frenchb.
%
%    When French is \babel’s main language, \frenchb{}
%    makes the following changes to the global layout, \emph{both in
%    French and in all other languages}\footnote{%
%     For each item, hooks are provided to reset standard
%     LaTeX settings or to emulate the behaviour of former versions
%     of \frenchb{} (see command \fbsetup{},
%     section~\ref{ssec-custom} p.~\pageref{ssec-custom}).}:
%    \begin{enumerate}
%    \item the first paragraph of each section is indented
%          (LaTeX only);
%    \item the default items in itemize environment are set to `---’
%          instead of `\textbullet’, and all vertical spacing and glue
%          is deleted; it is possible to change `---’ to something else
%          (`--’ for instance) using \fbsetup{} (see
%          section~\ref{ssec-custom} p.~\pageref{ssec-custom});
%    \item vertical spacing in general LaTeX lists is
%          shortened;
%    \item footnotes are displayed ``à la française’’.
%    \end{enumerate}
%
%    Regarding local typography, the command |\selectlanguage{french}|
%    switches to the French language\footnote{%
%      \cs{selectlanguage\{francais\}} and
%      \cs{selectlanguage\{frenchb\}} are no longer supported.},
%    with the following effects:
%    \begin{enumerate}
%    \item French hyphenation patterns are made active;
%    \item `high punctuation’ characters (|:| |;| |!| |?|)
%           automatically add correct spacing in French; this is
%           achieved using callbacks in Lua(La)TeX, these characters
%           are no longer made ``active’’;
%    \item |\today| prints the date in French;
%    \item the caption names are translated into French
%          (LaTeX only).  For customisation of caption names see
%          section~\ref{sssec-captions-name}
%          p.~\pageref{sssec-captions-name}.
%    \item the space after |\dots| is removed in French.
%    \end{enumerate}
%
%    Some commands are provided by \frenchb{} to make typesetting
%    easier:
%    \begin{enumerate}
%    \item French quotation marks can be entered using the command
%      |\frquote{}|: |\frquote{some text}| will output
%      «~some text~».  Former commands |\og| and |\fg| are kept
%      for backward compatibility only: |\og some text\fg{}| produces
%      the same output as |\frquote{some text}|.\hlabel{frquote}
%
%      If French quote characters are available on your keyboard,
%      you can use them, the required nobreak spaces will be added
%      automatically: you can type either
%      \texttt{« guillemets »} or \texttt{«guillemets»}%
%      \footnote{Or even
%         \texttt{«\textasciitilde{}guillemets\textasciitilde{}»}…}
%      (with or without spaces) to get properly typeset French quotes.
%      The same is true for the single guillemets ‹~and~›.
%
%      For quotations spreading over more than one paragraph,
%      |\frquote| will add at the beginning of every paragraph of
%      the quotation either an opening French guillemet («), or
%      a closing one (») or nothing depending on option
%      \fbo{EveryParGuill=open} or \fbo{=close} or \fbo{=none},
%      see p.~\pageref{everyparguill}.\\
%      The command |\NoEveryParQuote| is provided to locally suppress
%      unwanted guillemets (typically when lists are embedded in
%      |\frquote{}|), it must be used inside an environment
%      or a group \emph{only}.
%
%      |\frquote| is recommended to enter embedded quotations ``à la
%      française’’, several variants are provided through options:
%      \begin{itemize}
%        \item the inner quotation
%          is surrounded by double quotes (``\textit{texte}’’)
%          unless option \fbo{InnerGuillSingle=true}, then
%          a) the inner quotation is printed as
%            \guilsinglleft\textit{texte}\guilsinglright{} and
%          b) if the inner quotation
%            spreads over more than one paragraph, every paragraph
%            included in the inner quotation starts with
%            a \guilsinglleft{} or a \guilsinglright{} or nothing,
%            depending on option \fbo{EveryParGuill=open} (default)
%            or \fbo{=close} or \fbo{=none}.
%          \item it is possible to add a
%            French opening or closing guillemet (« or ») at the
%            beginning of every line of the inner quotation using
%            option \fbo{EveryLineGuill=open} or \fbo{=close}; note
%            that with any of these options, the inner quotation is
%            surrounded by French guillemets (« and ») regardless
%            option \fbo{InnerGuillSingle};
%            the default is \fbo{EveryLineGuill=none}.
%      \end{itemize}
%      A starred variant |\frquote*| is meant for inner quotations
%      which end together with the outer one: using |\frquote*| for
%      the inner quotation will print only one closing quote
%      character (the outer one) as recommended by the French
%      `Imprimerie Nationale’.
%
%    \item |\frenchdate|\marg{year}\marg{month}\marg{day} helps
%          typesetting dates in French: |\frenchdate{2001}{01}{01}|
%          will print 1\up{er} janvier 2001 in a box without any
%          linebreak.\label{frenchdate}
%
%    \item A command |\up| is provided to typeset superscripts like
%          |M\up{me}| (abbreviation for ``Madame’’), |1\up{er}| (for
%          ``premier’’).  Other commands are also provided for
%          ordinals: |\ier|, |\iere|, |\iers|, |\ieres|, |\ieme|,
%          |\iemes| (|3\iemes| prints 3\up{es}).
%          All these commands take advantage of real superscript
%          letters when they are available in the current font.
%
%    \item Command |\bname{}| (boxed name) is provided to typeset
%          family names: its argument will not be hyphenated except on
%          explicit hyphens.  |\bsc{}| (boxed small caps) is a variant
%          that prints its argument in small capitals, it is meant for
%          bibliographies, signatures, etc.
%          Usage: |Albert~\bsc{Camus}|.
%
%    \item Commands |\primo|, |\secundo|, |\tertio| and |\quarto|
%          print 1\up{o}, 2\up{o}, 3\up{o}, 4\up{o}.\linebreak
%          |\FrenchEnumerate{6}| prints 6\up{o}.
%    \item Abbreviations for ``Numéro(s)’’ and ``numéro(s)’’
%          (N\up{o} N\up{os} n\up{o} and n\up{os}~) are obtained
%          via the commands |\No|, |\Nos|, |\no|, |\nos|.
%
%    \item Two commands |\degre| and |\degres| are provided (for
%          backward compatibility only) to typeset the symbol ``degré’’.
%          Entering the raw character |°| is easier.
%
%    \item In math mode the comma has to be surrounded with
%          braces to avoid a spurious space being inserted after it,
%          in decimal numbers for instance (see the \TeX{}book p.~134).
%          The command |\DecimalMathComma| makes the comma behave as an
%          ordinary character \emph{when the current language is French}
%          (no space added);
%          as a counterpart, if |\DecimalMathComma| is active, an
%          explicit thin space has to be added in lists and intervals:
%          |$(x,\,y)$|, |$[0,\,1]$|.  |\StandardMathComma| switches
%          back to the standard behaviour of the comma in French.
%
%          The \pkg{icomma} package is an alternative workaround.
%
%    \item A command |\nombre| was provided in 1.x versions to easily
%          format numbers in slices of three digits separated either
%          by a comma in English or with a space in French; |\nombre|
%          is now mapped to |\numprint| from \file{numprint.sty}, which
%          should be loaded \emph{after} \babel, see \file{numprint.pdf}
%          for more information.
%
%    \item \frenchb{} has been designed to take advantage of the
%          \pkg{xspace} package if present: adding
%          |\usepackage{xspace}| in the preamble will force macros
%          like |\fg|, |\ier|, |\ieme|, |\dots|, …, to respect
%          the spaces you type after them, for instance typing
%          `|1\ier juin|’ will print `1\up{er} juin’
%           (no need for a forced space after |1\ier|).
%    \end{enumerate}
%
%  \subsection{Customisation}
%  \label{ssec-custom}
%
%    Customisation of \frenchb{} relies on command \fbsetup{}
%    (formerly called |\frenchbsetup{}|, the latter name will be kept
%    for ever to ensure backwards compatibility), options are entered
%    using the \file{l3keys} syntax.
%    The command \fbsetup{} is to appear in the preamble only
%    (after loading \babel).
%
%     \subsubsection[\textbackslash frenchsetup{}]
%     {\fbsetup{options}}
%     \label{sssec-frenchbsetup}
%
%    \vspace{.5\baselineskip}
%    |\frenchbsetup{}| and |\frenchsetup{}| are synonymous;
%    the latter should be preferred as the language name for
%    French in \babel{} is no longer |frenchb| but |french|.
%
%    \fbsetup{ShowOptions} prints all available options to
%    the \file{.log} file, it is just meant as a remainder of the
%    list of offered options.  As usual with \file{l3keys} syntax,
%    boolean options (as \fbo{ShowOptions}) can be entered as
%    \fbo{ShowOptions=true} or just \fbo{ShowOptions}, the
%    \fbo{=true} part can be omitted.
%
%    \vspace{.5\baselineskip}
%    The other options are listed below.  Their default value is
%    shown between braces, sometimes followed be a `\texttt{*}’.
%    The `\texttt{*}’ means that the default shown applies when
%    \frenchb{} is loaded as the \emph{last} option of \babel{}
%    ---\babel’s \emph{main language}---, and is toggled otherwise.
%
%    \vspace{\baselineskip}
%    \centerline{\bfseries General Layout}
%
%    \begin{description}[labelsep=0pt]
%    \item [\fbo{StandardLayout=true (false*)}]\ forces \frenchb{} not to
%      interfere with the layout: no action on any kind of lists,
%      first paragraphs of sections are not indented (as in English),
%      no action on footnotes; it useless unless French is the main
%      language.  This option can be used to avoid conflicts with
%      classes or packages which customise lists or footnotes.
%
%    \item [\fbo{IndentFirst=false (true*)}]; set this option to \fbo{false}
%      if you do not want \frenchb{} to  force indentation of the
%      first paragraph of sections.  When French is the main language,
%      this option applies to all languages.
%
%    \item [\fbo{PartNameFull=false (true)}]; when true (the default),
%      \frenchb{} numbers the title of |\part{}| commands as
%      ``Première partie’’, ``Deuxième partie’’ and so on.
%      With some classes which
%      change the |\part{}| command (AMS classes do so), you could
%      get ``Première partie~1’’, ``Deuxième partie~2’’ in the toc;
%      when this occurs, this option should be set to
%      \fbo{false}, part titles will then be printed as ``Partie I’’,
%      ``Partie II’’.
%
%    \item [\fbo{TocPartNameFull=false (true*)}]; when true (default),
%      parts are also numbered ``Première partie’’, ``Deuxième partie’’,
%      in the table of contents. This works currently only for the
%      \cls{memoir} and koma-script classes (standard classes do not
%      provide (yet?) any hook to customise the TOC).  \frenchb{} provides
%      a command |\FBtocpartname{|\meta{Romannum}|}| which returns
%      the formatted string (``Deuxième partie’’ if the argument is
%      ``II’’), it can be used with all classes; it is possible to add
%      something (colon, dot,…) at the end of the string by redefining
%      |\FBtocpartsep|: |\renewcommand*{\FBtocpartsep}{. }| adds a dot.
%    \end{description}
%
%      \centerline{\bfseries Lists Layout%
%      \footnote{Two options, NosepItemize and NosepEnumerate, require the
%        new templates, \textit{i.e.}\ a \cs{DocumentMetadata}\{\} command.}}
%
%    \begin{description}[labelsep=0pt]
%    \item [\fbo{ListItemsAsPar=true (false)}]; setting this option to
%      \fbo{true} is recommended: list items will be displayed as
%      paragraphs with indented labels (in the ``Imprimerie Nationale’’
%      way) instead of having labels hanging into the left margin.
%      How these two layouts differ is shown below:\\[.5\baselineskip]
%          \fbox{\parbox[t]{.4\textwidth}{\raggedright
%            \parindent=1.5em
%            \settowidth{\labelwidth}{\textemdash}%
%            Text starting at `parindent’\par
%            \noindent<= Leftmargin\par
%            \textemdash{} first item running on two
%              \hspace*{\parindent}\hspace*{\labelwidth}
%                lines or more…\par
%              \hspace*{\labelwidth} \textemdash{} first second level
%                item \hspace*{\parindent}\hspace*{\labelwidth}%
%                  \hspace*{\labelwidth} on two lines…\par
%              \hspace*{\labelwidth} \textemdash{} next one…\par
%            \textemdash{} second item…
%          }}
%          \hfill \hlabel{ListAsPar}%
%          \fbox{\parbox[t]{.4\textwidth}{\raggedright
%            \parindent=1.5em
%            \settowidth{\labelwidth}{\textemdash}%
%            Text starting at `parindent’ \\
%            \noindent<= Leftmargin\par
%            \textemdash{} first item running on two
%                lines or more…\par
%              \hspace*{\labelwidth} \textemdash{} first second level
%                item \hspace*{\parindent}on two lines…\par
%              \hspace*{\labelwidth} \textemdash{} next one…\par
%            \textemdash{} second item…
%          }}\par
%            \hspace*{3em} Default French layout%
%            \hspace{\fill}With \fbo{ListItemsAsPar=true} \hspace*{1em}
%
%    \item [\fbo{StandardListSpacing=true (false*)}]%
%      \footnote{This option should be used instead of former option
%      \fbo{ReduceListSpacing} (kept for backward compatibility) which
%      could be misleading: with some classes (smfart, smfbook f.i.)
%      you had to set \fbo{ReduceListSpacing=false} to revert to the
%      class settings which actually reduce list’s spacings even more
%      than \frenchb! \fbo{StandardListSpacing=true} replaces
%      \fbo{ReduceListSpacing=false}.}; \frenchb{} usually customises
%      the vertical spaces in the \env{list} environment, this affects
%      all lists, including \env{itemize}, \env{enumerate},
%      \env{description}, but also \env{abstract}, \env{quote},
%      \env{quotation}, \env{verse}, etc. which are based on \env{list}.
%      Setting this option to \fbo{true} reverts to the standard
%      settings of the \env{list} environment as defined by the document
%      class.
%
%    \item [\fbo{NosepItemize=true (true*)}]; turning this option
%      to \fbo{false} slightly enlarges the vertical spaces included in
%      \env{itemize} lists to match their counterparts in \env{enumerate}
%      and \env{description} lists.
%
%    \item [\fbo{NosepEnumerate=true (false*)}]; turning this option
%      to \fbo{true} suppresses any vertical space in \env{enumerate}
%      and \env{description} lists, to match \env{itemize} lists.
%
%    \item [\fbo{StandardItemLabels=true (false*)}]; when set to \fbo{true}
%      this option prevents \frenchb{} from changing the labels in
%      \env{itemize} lists in French.
%
%    \item [\fbo{ItemLabels=\cs{textbullet}, \cs{textendash},
%           \cs{ding\{43\}},  (\cs{textemdash}*)}]; \\
%      when \fbo{StandardItemLabels=false} (the default), this option
%      enables to choose the label used in French \env{itemize} lists
%      for all levels.  The next four options do the same but each
%      one for a specific level only.  Note that \fbo{\cs{ding\{43\}}}
%      requires loading the \pkg{pifont} package.
%
%    \item [\fbo{ItemLabeli=\cs{textbullet}, \cs{textendash},
%           \cs{ding\{43\}} (\cs{textemdash}*)}]
%
%    \item [\fbo{ItemLabelii=\cs{textbullet}, \cs{textendash},
%           \cs{ding\{43\}} (\cs{textemdash}*)}]
%
%    \item [\fbo{ItemLabeliii=\cs{textbullet},
%           \cs{textendash}, \cs{ding\{43\}} (\cs{textemdash}*)}]
%
%    \item [\fbo{ItemLabeliv=\cs{textbullet}, \cs{textendash},
%           \cs{ding\{43\}} (\cs{textemdash}*)}]\hfill
%
%    \item [\fbo{StandardLists=true (false*)}]\ forbids \frenchb{} to
%      customise any kind of list.  The option \fbo{StandardLists=true}
%      should be used in case of conflicts with classes or packages that
%      customise lists too.
%    \end{description}
%
%      \centerline{\bfseries Footnotes layout}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{FrenchFootnotes=false (true*)}]\ reverts to the standard
%      layout of footnotes.  By default \frenchb{} typesets leading
%      numbers as `1.\hspace{.5em}’ instead of `\up{1}’, but does not
%      change footnotes numbered with symbols (as in the |\thanks|
%      command) or with letters (as in minipages).
%
%    \item [\fbo{AutoSpaceFootnotes=false (true*)}]; by default \frenchb{}
%      adds a (customisable) thin space in the running text before the
%      number or symbol calling the footnote.  Making this option
%      \fbo{false} reverts to the standard setting (no space added).
%      The default definition of this thin space is:\\
%      |\newcommand*{\FBfnmarkspace}{\kern .5\fontdimen2\font}|
%   \end{description}
%
%      \centerline{\bfseries Punctuation}
%
%   \begin{description}[labelsep=0pt]
%    \item [\fbo{AutoSpacePunctuation=false (true)}]; with Lua(La)TeX
%      changing this option to \fbo{false} doesn’t make sense as the
%      LuaTeX callback takes care of special cases where no space should
%      be added: URLs (http://mysite), in MS-DOS paths
%      (C:\textbackslash Foo) or in timetables (10:55).
%      \hlabel{autospacepunctuation}.
%
%    \item [\fbo{ThinColonSpace=true (false)}]\ changes the
%      non-breaking space added before the colon `:’ to a thin space,
%      so that the same amount of space is added before any of the
%      four `high punctuation’ characters.  The default setting is
%      supported by the French `Imprimerie Nationale’.
%
%    \item [\fbo{OriginalTypewriter=true (false)}]\ prevents any
%      customisation of |\ttfamily| and |\texttt{}| in French.
%      This option should only be used to ensure backward compatibility.
%      The current default behaviour is to switch off any addition of
%      space before high punctuation with typewriter fonts
%      (\textit{e.g.} verbatim).
%
%    \item [\fbo{UnicodeNoBreakSpaces=true (false)}];\hlabel{ucs-nbsp}
%      (experimental) this option should be set to \fbo{true}
%      \emph{only while converting LuaLaTeX files} to HTML.
%      It ensures that non-breaking spaces added by \frenchb{} are
%      inserted in the PDF file as U+A0 or U+202F (thin) instead of
%      penalties and glues.
%      Note that \exe{lwarp} (v.~0.37 and up) is fully compatible with
%      \frenchb{} for translating PDFLaTeX or XeLaTeX files to HTML.
%  \end{description}
%
%      \centerline{\bfseries French quotes}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{og=«, fg=»}]; this option has been kept for backward
%      compatibility but has no effect in Lua(La)TeX, it just prints
%      a warning in the \file{.log} file.
%
%    \item [\fbo{INGuillSpace=true (false)}]\ resets the dimensions of spaces
%      after opening French quotes and before closing French quotes to
%      the French `Imprimerie Nationale’ standards (inter-word space).
%      \frenchb’s default setting produces slightly narrower spaces
%      with less stretchability.
%
%    \item [\fbo{EveryParGuill=open, close, none (open)}]; sets whether
%      an opening quote (\texttt{«}) or a closing one (\texttt{»}) or
%      nothing should be printed by |\frquote{}| at the beginning of
%      every parapraph included in a level 1 (outer) quotation.
%      This option is also considered for level 2 (inner) quotations
%      to decide between \texttt{\guilsinglleft} and
%      \texttt{\guilsinglright} when \fbo{InnerGuillSingle=true}
%      (see below). \hlabel{everyparguill}
%    \item [\fbo{EveryLineGuill=open, close, none (none)}]; with LuaTeX
%      based engines \emph{only}, it is possible to set this option
%      to \fbo{open} [resp. \fbo{close}]; this ensures that a `«’
%      [resp. `»’] followed by a proper space will be inserted at the
%      beginning of every line of embedded (inner) quotations
%      spreading over more than one line (provided that both outer
%      and inner quotations are entered with |\frquote{}|). When
%      \fbo{EveryLineGuill=open} or \fbo{=close} the inner quotation is
%      always surrounded by « and », the next option is ineffective.
%
%    \item [\fbo{InnerGuillSingle=true (false)}];
%      if \fbo{InnerGuillSingle=false} (the default), inner quotations
%      entered with |\frquote{}| start with~\texttt{``} and end
%      with~\texttt{’’}.
%      If \fbo{InnerGuillSingle=true}, \texttt{\guilsinglleft} and
%      \texttt{\guilsinglright} are used instead of British double
%      quotes; moreover if option \fbo{EveryParGuill=open} (or
%      \fbo{close}) is set, a \texttt{\guilsinglleft} (or
%      \texttt{\guilsinglright}) is added at the beginning of every
%      parapraph included in the inner quotation.
%  \end{description}
%
%      \centerline{\bfseries Numbers}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{ThinSpaceInFrenchNumbers=true (false)}]; if \pkg{numprint}
%      has been loaded with the \opt{autolanguage} option, while
%      typesetting numbers with the |\numprint{}| command,
%      |\npthousandsep| is defined as a non-breaking space (|~|)%
%      \footnote{Actually without stretch nor shrink.} in French;
%      when set to true, this option redefines |\npthousandsep|
%      as a thin space (|\FBthinspace|).
%  \end{description}
%
%      \centerline{\bfseries Figure and table captions}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{SmallCapsFigTabCaptions=false (true*)}]; when set to
%      \fbo{false}, |\figurename| and |\tablename| will be printed in
%      French captions as ``Figure’’ and ``Table’’ instead of being
%      printed in small caps (the default). The same result can be
%      achieved by defining |\FBfigtabshape| as |\relax| before
%      loading \frenchb{} (in a document class f.i.).
%
%    \item [\fbo{CustomiseFigTabCaptions=true (false)}]; this option is now
%      \fbo{false}, as the colon in captions is no printed properly in
%      French with LuaTeX; turning it to \fbo{true} prints a warning and
%      changes the caption’s separator into endash to mimic former
%      versions of \frenchb{}. Not recommended, see below (section
%      \ref{sssec-captions-fig}) for hints to customise captions.
%  \end{description}
%
%      \centerline{\bfseries Superscripts}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{FrenchSuperscripts=false (true)}]; the \frenchb’ |\up{}|
%      command should print better superscripts than |\textsuperscript|;
%      turning this option to \fbo{false} redefines |\up{}| as
%      |\textsuperscript| (not recommended, except if |\up{}| fails).
%
%    \item [\fbo{LowercaseSuperscripts=false (true)}]; by default \frenchb{}
%      inhibits the uppercasing of superscripts (for instance when
%      they are moved to page headers).  Making this option
%      \fbo{false} will disable this behaviour (not recommended).
%  \end{description}
%
%      \centerline{\bfseries Warnings}
%
%  \begin{description}[labelsep=0pt]
%    \item [\fbo{SuppressWarning=true (false)}]; can be turned to \fbo{true}
%      if you are bored with \frenchb’s warnings; use this option as
%      \emph{first} option of \fbsetup{} to cancel warnings launched
%      by other options.
%  \end{description}
%
%    \textbf{Options’ order} ---%
%    Please remember that options are read in the order they appear in
%    the \fbsetup{} command.  Someone wishing that \frenchb{} leaves the
%    layout of lists and footnotes untouched but caring for indentation
%    of first paragraph of sections should choose
%    \fbsetup{StandardLayout,IndentFirst}. %\par
%    The reverse order \fbsetup{IndentFirst,StandardLayout} would lead
%    to option \fbo{IndentFirst} being overwritten by
%    \fbo{StandardLayout}.
%
%  \subsubsection{Caption names}
%  \label{sssec-captions-name}
%
%    {\sloppy All caption names can easily be customised in French
%    using the simplified syntax introduced by \babel~3.9,
%    for instance |\def\frenchproofname{Preuve}|.
%    The older syntax |\addto\captionsfrench{\def\proofname{Preuve}}|
%    still works.\par}
%
%  \pagebreak[4]
%  \subsubsection{Figure and table captions}
%  \label{sssec-captions-fig}
%
%    Most document classes use a colon as  captions’ separator in figures
%    and tables like this: `Figure 1:~’.  With 8-bits engines (TeX,
%    pdfTeX) the colon was made active too late to ensure a proper space
%    before it.
%    The problem has vanished with LuaTeX. Therefore, the
%    former patches provided in the legacy versions of \frenchb{} have
%    been dropped: |\CaptionSeparator| is no longer defined and the
%    \fbo{CustomiseFigTabCaptions} option is now turned to \fbo{false}
%    by default.  Switching it to \fbo{true}, prints a Warning in the
%    \file{.log} file and currently turns the captions’ separator into
%    an endash (this might change in the future).
%
%    Customisation of the captions’ separator should be achieved
%    outside \frenchb{}; here are some hints for those who want to get
%    the endash formerly provided by \frenchb{}:
%    \begin{itemize}
%    \item with standard classes \cls{article}, \cls{book},
%      \cls{report}, use \file{caption.sty}:\\
%      |\usepackage[labelsep=endash]{caption}|
%    \item with the \cls{memoir} class, just add:\\
%      |\captiondelim{\space\textendash\space}|
%    \item with the koma-script classes, just add:\\
%      |\renewcommand{\captionformat}{\space\textendash\space}|
%    \item with the \cls{beamer} class, just add:\\
%      |\setbeamertemplate{caption label separator}[endash]|
%    \end{itemize}
%
%    Following the IN’s recommendations, |\figurename| and |\tablename|
%    should be typeset in small caps in French, \frenchb{} provides
%    the \fbo{SmallCapsFigTabCaptions} option (default is \fbo{true}) to
%    do so.  It can be set to \fbo{false} to typeset
%    |\figurename| and |\tablename| in French as ``Figure’’ and ``Table’’
%    rather than in small caps (the default).
%
%  \newpage
%  \subsection{Hyphenation checks}
%  \label{ssec-hyphen}
%
%    Once you have built your format, a good precaution would be to
%    perform some basic tests about hyphenation in French.
%    For LaTeX2e I suggest this:
%    \begin{itemize}
%    \item run |LuaLaTeX| on the following file:\\[3mm]^^A\]
%      |%%% Test file for French hyphenation.|\\
%      |\documentclass[french]{article}|\\
%      |\usepackage{fontspec}       % mandatory for French|\\
%      |\setmainfont{NewCM10-Book}  % or erewhon, XCharter…|\\
%      |\usepackage{babel}|\\
%      |\begin{document}|\\
%      |\showhyphens{signal container événement algèbre}|\\
%      |\end{document}|
%    \item check the hyphenations proposed by \TeX{} in your log-file;
%      in French you should get \\
%      \texttt{si-gnal contai-ner évé-ne-ment al-gèbre}.\\
%      Do not care about how accented characters are displayed in the
%      log-file, what matters is the position of the `|-|’ hyphen
%      signs \emph{only}.
%    \end{itemize}
%    If they are all correct, your installation (probably) works fine,
%    if one (or more) is (are) wrong, ask a local wizard to see what’s
%    going wrong and perform the test again (or e-mail me about what
%    happens).\\
%    Possible mismatches: you get |sig-nal con-tainer|, this probably
%    means that the hyphenation patterns you are using are for
%    US-English, not for French.
%
%  \newpage
%  \subsection{Changes}
%  \label{ssec-changes}
%
%  \subsubsection*{What’s new in version 4.1?}
%
%    Options \opt{acadian}, \opt{canadian}, \opt{frenchb} and
%    \opt{francais} are no longer supported, the only possible Babel’s
%    option for French is \opt{french}; anyway \frenchb{} is customisable
%    enough to fit any French dialect, see |\fbsetup{}|
%    p.\pageref{ssec-keyval}.
%
%    If French is \emph{not} the document’s main language, the layout
%    remains unchanged, \textit{i.e.} is unaffected by the changes
%    introduced in this version.
%
%    This version aims at compatibility with the new templates
%    introduced by the LaTeX Team for the PDF tagging project.
%    These new templates are part of the 2026-06-01 LaTeX release.
%
%    As LuaTeX users may add a |\DocumentMetadata{ ... }| command
%    (involving the new templates) or not (then legacy code is used),
%    new code has been added to enable the customisation of lists and
%    footnotes using the new templates.
%
%    When a |\DocumentMetadata{ ... }| command is detected,
%    \file{french.ldf} automatically switches from legacy to new code.
%    A warning is issued in case the LaTeX format is older than
%    2026-06-01.
%
%    The new templates have positive side-effects, \pkg{babel-french}
%    becomes f.i.\ compatible with \pkg{enumitem} and \pkg{footmisc}.
%
%    \subsubsection*{What’s new in version 4.0?}
%
%    \frenchb{} has been split into two files \file{frenchb3.dtx}, the
%    legacy part, which is frozen, is meant for TeX, pdfTeX and XeTeX
%    engines, and \file{frenchb.dtx} for LuaTeX \emph{only}.
%
%    This has made possible to deeply simplify the current file
%    \file{frenchb.dtx}, stripping old code which no longer makes sense
%    with Lua(La)TeX.
%
%    Consequently, some \fbsetup{} options have been modified, deleted
%    or added:
%    \begin{itemize}
%      \item \opt{AutoPunctuation} \emph{should not be turned to}
%        \fbo{false} with LuaLaTeX, a warning in \file{.log} file is
%        issued if you do so; \file{frenchb.lua} now handles automatically
%        the special cases (|2:1|, |\http://|, |C:\|, |!!|, etc.)
%        requiring no space before high punctuation.
%      \item \verb|\frenchsetup{og=«, fg=»}| is useless, it just prints
%        a warning; single and double French quotes (« and », ‹ and ›)
%        automatically add the required spaces, it is still possible to
%        inhibit this locally using |{\NoAutospacing }|.
%      \item \opt{CustomiseFigTabCaptions} is now \fbo{false}, it means
%        that \frenchb{} no longer customises the captions’ separator
%        (usually a colon); when forced to \fbo{true}, it issues
%        a warning and turns the separator to en endash, see
%        section~\ref{sssec-captions-fig} for better options.
%      \item Options \opt{OldFigTabCaptions}, \opt{ListOldLayout} and
%        \opt{GlobalLayoutFrench} have been deleted (they emulated very
%        old behaviours of \frenchb{}).
%      \item a new option \opt{TocPartFullName} has been added to
%        enhance \opt{PartFullName}. When \fbo{true} (the default), the
%        numbered parts are printed as  ``Première partie’’,
%        ``Deuxième partie’’ in the table of contents too. This works
%        currently only with the \cls{memoir} and koma-script classes.
%    \end{itemize}
%
%    \file{frenchb.lua} has a new function |euphonic_t| to deal with
%    compound words’ hyphenation like ``va-t-on’’, ``semble-t-il’’ etc.
%    A bug occuring in case |\spaceskip| is not null has been fixed.
%
%    Version~4.0b takes advantage of the new footnotes’ template (when
%    it is available) to customise the footnotes’ layout. This should
%    fix issue
%    \href{https://github.com/latex3/tagging-project/issues/932}{932}.
%
%    Version~4.0: commands |\StandardFootnotes| and |\FrenchFootnotes|
%    are no longer available when neww templates are used: footnotes
%    inside minipages are now numbered the standard way with both new
%    and old interface.
%
%    \subsubsection*{What’s new in version 3.7?}
%
%    The \opt{acadian}  dialect is no longer
%    supported: |\usepackage[acadian]{babel}| prints a warning
%    and uses \opt{french} instead. Reason: I have never got feedback
%    from anybody using them; anyway \frenchb{} is customisable enough to
%    fit any French dialect, see |\fbsetup{}| p.\pageref{ssec-keyval}.
%
%    Version~3.7 is the frozen version in \file{frenchb3.dtx}.
%
%  \subsubsection*{What’s new in version 3.6?}
%
%    Version 3.6a no longer loads the \pkg{keyval} package, replaced by
%    core LaTeX commands (\pkg{l3keys}). The thin space added before
%    footnote’s calls is now customisable (suggested by Thomas Savary),
%    the command’s name is |\FBfnmarkspace|.
%
% \StopEventually{}
%
%  \clearpage
%  \newgeometry{left=50mm,right=23mm}
%
%  \section{The code}
%
%  \subsection{Initial setup}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%
%    \begin{macrocode}
%<*french>
\LdfInit\CurrentOption{FBclean@on@exit}
%    \end{macrocode}
%    If the engine is not LuaTeX, revert to the version 3.7 of
%    babel-french.
%    \begin{macrocode}
\let\bbl@tempa\relax
\ifnum\bbl@engine=\@ne \else \input french3.ldf\relax
  \let\bbl@tempa\endinput
\fi
\bbl@tempa
%    \end{macrocode}
%
%    The rest of this file is \emph{only for the Luatex engine}.
%
%    Let’s provide a substitute for |\PackageError|, |\PackageWarning|
%    and |\PackageInfo| not defined in Plain:
%    \begin{macrocode}
\def\fb@error#1#2{%
    \begingroup
      \newlinechar=`\^^J
      \def\\{^^J(french.ldf) }%
      \errhelp{#2}\errmessage{\\#1^^J}%
    \endgroup}
\def\fb@warning#1{%
   \begingroup
      \newlinechar=`\^^J
      \def\\{^^J(french.ldf) }%
      \message{\\#1^^J}%
   \endgroup}
\def\fb@info#1{%
   \begingroup
      \newlinechar=`\^^J
      \def\\{^^J}%
      \wlog{#1}%
   \endgroup}
%    \end{macrocode}
%    Quit if the LuaTeX engine is too old.
%    \begin{macrocode}
\ifnum\luatexversion<100
    \ifx\PackageWarning\@undefined
      \fb@warning{Please upgrade LuaTeX to version 1.1 or above!\\%
         Aborting.}%
    \else
      \PackageWarning{french.ldf}{Please upgrade LuaTeX
         to version 1.1 or above!\MessageBreak
         Aborting. Reported}%
    \fi
  \let\bbl@tempa\endinput
\fi
\bbl@tempa
%    \end{macrocode}
%
%    Quit if \babel’s version is less than 24.1.
%    \begin{macrocode}
\let\bbl@tempa\relax
\ifdefined\babeltags
\else
   \let\bbl@tempa\endinput
   \ifdefined\PackageError
      \PackageError{french.ldf}
         {babel-french requires babel v.24.1.\MessageBreak
          Aborting here}
         {Please upgrade Babel!}
   \else
      \fb@error{babel-french requires babel v.24.1.\\
                Aborting here}
               {Please upgrade Babel!}
   \fi
\fi
\bbl@tempa
%    \end{macrocode}
%
%    Make sure that |\l@french| is defined (fallbacks are
%    |\l@nohyphenation| if available or~0).
%    \file{babel.def} (3.9i and up) defines |\l@<languagename>| also for
%    eTeX, LuaTeX and XeTeX formats which set |\lang@<languagename>|.
%    \begin{macrocode}
\def\FB@nopatterns{%
   \ifdefined\l@nohyphenation
      \adddialect\l@french\l@nohyphenation
      \edef\bbl@nulllanguage{\string\language=nohyphenation}%
   \else
      \edef\bbl@nulllanguage{\string\language=0}%
      \adddialect\l@french0
   \fi
   \@nopatterns{French}}
\ifdefined\l@french \else \FB@nopatterns \fi
%    \end{macrocode}
%
%    French uses the standard values of |\lefthyphenmin| (2)
%    and |\righthyphenmin| (3); let’s provide their values though,
%    as required by \babel.
%
%    \begin{macrocode}
\providehyphenmins{french}{\tw@\thr@@}
%    \end{macrocode}
%
% \begin{macro}{\ifLaTeXe}
%    No support is provided for late LaTeX-2.09: issue a warning
%    and exit if LaTeX-2.09 is in use.  Plain is still supported.
%    \begin{macrocode}
\newif\ifLaTeXe
\let\bbl@tempa\relax
\ifdefined\magnification
\else
   \ifdefined\@compatibilitytrue
     \LaTeXetrue
   \else
     \PackageError{french.ldf}
        {LaTeX-2.09 format is no longer supported.\MessageBreak
         Aborting here}
        {Please upgrade to LaTeX2e!}
     \let\bbl@tempa\endinput
   \fi
\fi
\bbl@tempa
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifFBfrench}
%    True when the current language is French;
%    will be set to true by |\extrasfrench| and to false by
%    |\noextrasfrench|.  Used in |\DecimalMathComma|.
%    \begin{macrocode}
\newif\ifFBfrench
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extrasfrench}
% \begin{macro}{\noextrasfrench}
%    The macro |\extrasfrench| will perform all the extra
%    definitions needed for the French language.
%    The macro |\noextrasfrench| is used to cancel the actions of
%    |\extrasfrench|.
%
%    In French, character ``apostrophe’’ (U+27 or U+2019) is a letter in
%    expressions like |l’ambulance| (French hyphenation patterns provide
%    entries for this kind of words).  This means that the |\lccode| of
%    ``apostrophe’’ has to be non null in French for proper hyphenation
%    of those expressions, and has to be reset to null when exiting
%    French.
%
%    \begin{macrocode}
\def\extrasfrench{%
     \FBfrenchtrue
     \babel@savevariable{\lccode"27}%
     \lccode"27="27
     \babel@savevariable{\lccode"2019}%
     \lccode"2019="2019
     \bbl@frenchspacing
}
\def\noextrasfrench{\FBfrenchfalse \bbl@nonfrenchspacing}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \subsection{Punctuation}
%  \label{ssec-punct}
%
%    With LuaTeX, callbacks are used to
%    get rid of active punctuation.
%
% \begin{macro}{\FBguillspace}
% \begin{macro}{\FBcolonspace}
% \begin{macro}{\FBthinspace}
%    In French high punctuation characters (: ; ! ?) and guillemets
%    require some space to be added before them (: ; ! ? » ›) or after
%    them («, ‹).
%    Following the I.N.\ specifications, the `:’ requires an
%    inter-word space before it, the other three require just a thin
%    space.  So we define |\FBcolonspace| as |\space| (inter-word space)
%    and |\FBthinspace| as an half inter-word space with no shrink nor
%    stretch.
%    |\FBguillspace| is meant for guillemets; it has been fine tuned by
%    Thierry Bouche to 80\% of an inter-word space with reduced
%    stretchability.
%    All three are user customisable in the preamble, best using the
%    |\FBsetspaces| command described below.
%    These three commands are designed for basic French.  Other French
%    dialects can use different settings, see below.
%
%    A penalty will be added before these spaces to prevent line
%    breaking.
%    \begin{macrocode}
\newcommand*{\FBguillspace}{\hskip .8\fontdimen2\font
                              plus .3\fontdimen3\font
                             minus .8\fontdimen4\font \relax}
\newcommand*{\FBcolonspace}{\space}
\newcommand*{\FBthinspace}{\hskip .5\fontdimen2\font \relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FBsetspaces}
%    This command makes it easy to fine tune |\FBguillspace|,
%    |\FBcolonspace| and\linebreak |\FBthinspace| in French
%    using the optional argument.
%    It is meant for LaTeX2e \emph{only} and can only be used
%    in the preamble.
%    Four mandatory arguments\footnote{%
%    The former optional \opt{lang} argument no longer has any effect.}:
%    the first one is a \textit{string} either "guill", "colon", or
%    "thin", the last three are decimal numbers specifying
%    \textit{width}, \textit{stretch} and \textit{shrink} relative to
%    the relevant \textit{fontdimens}.\hlabel{FBsetspaces}
%    For instance |\FBsetspaces{colon}{0.5}{0}{0}| defines
%    |\FBcolonspace| as a thinspace as suggested by the
%    ``Guide du typographe Roman’’.
%    \begin{macrocode}
\ifLaTeXe
  \newcommand*{\FBsetspaces}[5][french]{%
    \@namedef{FB#2space}{\hskip #3\fontdimen2\font
                           plus #4\fontdimen3\font
                          minus #5\fontdimen4\font \relax}}
  \@onlypreamble\FBsetspaces
\fi
%    \end{macrocode}
% \end{macro}
%
%    We must set the LuaTeX tables for French after possible changes
%    made in the preamble (|\frenchsetup{}| or |\FBsetspaces{}|) and
%    before Babel switches to French at |\begin{document}|.
%    \begin{macrocode}
\ifLaTeXe
  \AddToHookNext{env/document/before}{%
    \set@glue@table{colon}%
    \set@glue@table{thin}%
    \set@glue@table{guill}%
  }
\fi
%    \end{macrocode}
%
%    This code is for Plain: load \file{ltluatex.tex} if it hasn’t been
%    loaded before \babel.
%    \begin{macrocode}
\ifdefined\newluafunction\else
    \input ltluatex.tex
    \ifdefined\bbl@attr@locale \else \newattribute\bbl@attr@locale \fi
    \newattribute\bbl@attr@locale
\fi
%    \end{macrocode}
%    We define five LuaTeX attributes to control spacing in French
%    for `high punctuation’ and quotes, making sure
%    that |\newattribute| is defined.
%
%    |\FB@spacing=0| switches off any space tuning both before high
%    punctuation characters and inside French quotes (i.e.\ function
%    |french_punctuation| doesn’t alter the node list at all).
%
%    |\FB@addDPspace=0| switches off automatic insertion of spaces
%    before high punctuation characters (but typed spaces are still
%    turned into non-breaking thin- or word-spaces).
%
%    |\FB@ucsNBSP| triggers the replacement of glues by characters, it
%    is controlled by option \fbo{UnicodeNoBreakSpaces}.
%
%    \begin{macrocode}
  \newattribute\FB@spacing      \FB@spacing=\@ne
  \newattribute\FB@addDPspace   \FB@addDPspace=\@ne
  \newattribute\FB@ucsNBSP      \FB@ucsNBSP=\z@
%    \end{macrocode}
%
%    {\sloppy The next command will be used in the first call of
%    |\extrasfrench| to convert |\FBcolonspace|, |\FBthinspace| and
%    |\FBguillspace| into a table usable by LuaTeX.
%    This way, any customisation done in the preamble (by \fbsetup{},
%    redefinitions or |\FBsetspaces| commands) are taken into account.
%    \par}

%    In case parsing by the Lua function |FBget_glue| (defined in file
%    \file{frenchb.lua}) fails due to unexpected syntax in |\FB...space|
%    the table remains unchanged and a warning is issued.
%    The matching space characters for option \fbo{UnicodeNoBreakSpaces}
%    are set as word space, thin space or null space according to the
%    \textit{width} parameter.
%
%    \begin{macrocode}
  \newcommand*{\set@glue@table}[1]{%
    \directlua {
      local s = token.get_meaning("FB#1space")
      local t = FBget_glue(s)
      if t then
         FBsp.#1.gl = t
         if FBsp.#1.gl[1] > 0.6 then
            FBsp.#1.ch = 0xA0
         elseif FBsp.#1.gl[1] > 0.2 then
            FBsp.#1.ch = 0x202F
         else
            FBsp.#1.ch = 0x200B
         end
      else
         texio.write_nl('term and log', '')
         texio.write_nl('term and log',
           '*** french.ldf warning: Unexpected syntax in FB#1space,')
         texio.write_nl('term and log',
           '*** french.ldf warning: LuaTeX table FBsp unchanged.')
         texio.write_nl('term and log',
           '*** french.ldf warning: Consider using FBsetspaces to ')
         texio.write('term and log', 'customise FB#1space.')
         texio.write_nl('term and log', '')
      end
    }%
  }
%</french>
%    \end{macrocode}
%
%    \begin{environment}{frenchb.lua}
%    This is \file{frenchb.lua}. It holds Lua code to deal with  `high
%    punctuation’ and quotes.  This code is based on suggestions from
%    Paul Isambert.
%
%    First we define two flags to control spacing before French `high
%    punctuation’ (thin space or inter-word space).
%
% \changes{v3.1a}{2014-06-16}{Codes 0x13 and 0x14 added for French
%    quotes in T1-encoding.}
%
% \changes{v4.0a}{2025-05-16}{Codes 0x2039 and 0x203A added for French
%    single quotes.}
%
%    \begin{macrocode}
%<*lua>
local FB_punct_thin =
  {[string.byte("!")] = true,
   [string.byte("?")] = true,
   [string.byte(";")] = true}
local FB_punct_thick =
  {[string.byte(":")] = true}
%    \end{macrocode}
%    Managing spacing for `»’ and `›’ (U+203A) can be done by the way;
%    we define two flags, |FB_punct_left| for characters requiring
%    some space before them and |FB_punct_right| for `«’ and `‹’ which
%    must be followed by some space.
%    In case LuaTeX is used to output T1-encoded fonts instead of
%    OpenType fonts, codes \texttt{0x13} and \texttt{0x14}  have to be
%    added for `«’ and `»’.
%    \begin{macrocode}
local FB_punct_left =
  {[string.byte("!")] = true,
   [string.byte("?")] = true,
   [string.byte(";")] = true,
   [string.byte(":")] = true,
   [0x14]             = true,
   [0xBB]             = true,
   [0x203A]           = true}
local FB_punct_right =
  {[0x13]             = true,
   [0xAB]             = true,
   [0x2039]           = true}
%    \end{macrocode}
%    Two more flags will be needed to avoid spurious spaces in
%    strings like !! ?? or (?)
%    \begin{macrocode}
local FB_punct_null =
  {[string.byte("!")] = true,
   [string.byte("?")] = true,
   [string.byte("[")] = true,
   [string.byte("(")] = true,
%    \end{macrocode}
%    or if the user has typed a non-breaking space U+00A0 or U+202F
%    (thin) before a `high punctuation’ character: no space
%    should be added by \frenchb.  Same is true inside French quotes.
%    \begin{macrocode}
   [0xA0]             = true,
   [0x202F]           = true}
local FB_guil_null =
  {[0xA0]             = true,
   [0x202F]           = true}
%    \end{macrocode}
%
%    Local definitions for nodes:
%    \begin{macrocode}
local new_node     = node.new
local copy_node    = node.copy
local node_id      = node.id
local HLIST        = node_id("hlist")
local TEMP         = node_id("temp")
local DISC         = node_id("disc")
local KERN         = node_id("kern")
local GLUE         = node_id("glue")
local GLYPH        = node_id("glyph")
local PENALTY      = node_id("penalty")
local nobreak      = new_node(PENALTY)
nobreak.penalty    = 10000
local nbspace      = new_node(GLYPH)
local insert_node_before = node.insert_before
local insert_node_after  = node.insert_after
local remove_node        = node.remove
%    \end{macrocode}
%
%    Commands |\FBthinspace|, |\FBcolonspace| and |\FBguillspace| are
%    converted `AtBeginDocument’ by the next function |FBget_glue| into
%    tables of three values which are fractions of |\fontdimen2|,
%    |\fontdimen3| and |\fontdimen4|. \hlabel{lua-scaling}
%    If parsing fails due to unexpected syntax, the function returns
%    \textit{nil} instead of a table.
%    \begin{macrocode}
function FBget_glue(toks)
  local t = nil
  local f = string.match(toks,
                         "[^%w]hskip%s*([%d%.]*)%s*[^%w]fontdimen 2")
  if f == "" then f = 1 end
  if tonumber(f) then
     t = {tonumber(f), 0, 0}
     f = string.match(toks,    "plus%s*([%d%.]*)%s*[^%w]fontdimen 3")
     if f == "" then f = 1 end
     if tonumber(f) then
        t[2] = tonumber(f)
        f = string.match(toks, "minus%s*([%d%.]*)%s*[^%w]fontdimen 4")
        if f == "" then f = 1 end
        if tonumber(f) then
           t[3] = tonumber(f)
        end
     end
  elseif string.match(toks, "[^%w]F?B?thinspace") then
     t = {0.5, 0, 0}
  elseif string.match(toks, "[^%w]space") then
     t = {1, 1, 1}
  end
  return t
end
%    \end{macrocode}
%    Let’s initialize the global LuaTeX table |FBsp|: it holds the
%    characteristics of the glues used in French for
%    high punctuation and quotes and the corresponding no-breaking
%    space characters for option \fbo{UnicodeNoBreakSpaces}.
%    \begin{macrocode}
FBsp = {}
FBsp.thin = {}
FBsp.thin.gl = {.5,  0,  0}
FBsp.thin.ch = 0x202F
FBsp.colon = {}
FBsp.colon.gl = {1,  1,  1}
FBsp.colon.ch = 0xA0
FBsp.guill = {}
FBsp.guill.gl = {.8, .3, .8}
FBsp.guill.ch = 0xA0
%    \end{macrocode}
%    The next function converts the glue table returned by function
%    |FBget_glue| into sp for the current font; beware of null values
%    for fid, see |\nullfont| in TikZ, and of special fonts like
%    lcircle1.pfb for which |font.getfont(fid)| does not return a proper
%    font table, in such cases the function returns |nil|.
%    |\spacekip|, when not null, replaces the inter-word space (in
%    raggedright env. f.i.). This is now taken into account.
%
% \changes{v4.0a}{2025-05-16}{Take non null values of \cs{spaceskip}
%    into account.  Bug pointed out by Enrico Gregorio.}
%
%    \begin{macrocode}
local font_table = {}
local function new_glue_scaled (fid,table)
  if fid > 0 and table[1] then
     local fp = font_table[fid]
     if not fp then
        local ft = font.getfont(fid)
        if ft then
           font_table[fid] = ft.parameters
           fp = font_table[fid]
        end
     end
     local gl = new_node(GLUE,0)
%    \end{macrocode}
%    |\spaceskip| is usually 0. In some circumstances (raggedright…)
%    it gets >~0 and then replaces the inter-word space.
%    \begin{macrocode}
     if fp then
        local spaceskip
        spaceskip = tex.get(tex.spaceskip)
        local spskip = spaceskip.width
        if spaceskip and spskip and spskip > 0 then
           node.setglue(gl, table[1]*spskip , 0, 0)
        else
           node.setglue(gl, table[1]*fp.space,
                            table[2]*fp.space_stretch,
                            table[3]*fp.space_shrink)
        end
        return gl
     else
        return nil
     end
  else
     return nil
  end
end
%    \end{macrocode}
%    Let’s catch LuaTeX attributes |\FB@spacing|, |\FB@addDPspace|
%    and |\FB@addGUILspace|.
%    \begin{macrocode}
local FBspacing    = luatexbase.attributes['FB@spacing']
local addDPspace   = luatexbase.attributes['FB@addDPspace']
local addGUILspace = luatexbase.attributes['FB@addGUILspace']
local FBucsNBSP    = luatexbase.attributes['FB@ucsNBSP']
local has_attribute = node.has_attribute
%    \end{macrocode}
%    The following function will be added to |kerning| callback.
%    It catches all nodes of type |GLYPH| in the list starting at
%    |head| and checks the language attributes of the current glyph:
%    nothing is done if the current language is not French and only
%    specific punctuation characters (those for which |FB_punct_left|
%    or |FB_punct_right| is true) need a special treatment.
%    In French, local variables are defined to hold the properties of
%    the current glyph (|item|) and of the previous one (|prev|) or the
%    next one (|next|).  The |FR| constant (french) is defined by
%    command |\activate@luacode|.
%
% \changes{v3.1b}{2014-09-16}{Add a check for null fid
%    in french\_punctuation (Tikz \cs{nullfont}).
%    Bug pointed out by Paul Gaborit.}
%
% \changes{v3.5g}{2020-01-30}{The kerning callback is a bit specific:
%    adding code with add\_to\_callback actually deletes the legacy
%    kerning as pointed out by Marcel Krüger on SE.}
%
% \changes{v3.5h}{2020-03-28}{Added glues and penalties should inherit
%    attributes from the related punctuation character; this is
%    mandatory for Lua-UL to underline and highlight them.
%    Thanks to Marcel Krüger for providing the fix.}
%
%    \begin{macrocode}
-- Main function (to be added to the kerning callback).
local function french_punctuation (head)
%    \end{macrocode}
%    Restore the built-in kerning for 8-bits fonts.
%    \begin{macrocode}
  node.kerning(head)
  for item in node.traverse_id(GLYPH, head) do
    local lang = item.lang
    local char = item.char
%    \end{macrocode}
%    Skip glyphs not concerned by French kernings.
%    \begin{macrocode}
    if lang == FR and (FB_punct_left[char] or FB_punct_right[char]) then
       local fid  = item.font
       local attr = item.attr
       local FRspacing = has_attribute(item, FBspacing)
       FRspacing = FRspacing and FRspacing > 0
       local FRucsNBSP = has_attribute(item, FBucsNBSP)
       FRucsNBSP = FRucsNBSP and FRucsNBSP > 0
       if FRspacing and fid > 0 then
          if FB_punct_left[char] then
             local prev = item.prev
             local prev_id, prev_subtype, prev_char
             if prev then
                prev_id = prev.id
                prev_subtype = prev.subtype
                if prev_id == GLYPH then
                   prev_char = prev.char
                end
             end
%    \end{macrocode}
%
% \changes{v3.0c}{2014-04-18}{Null glues should not trigger space
%    insertion before high ponctuation.  Bug pointed out by Benoit
%    Rivet for the `lstlisting’ environment of the listings package.}
%
%    If the previous node is a glue, check its natural width, only
%    positive glues (actually glues > 1 sp, for tabular `l’
%    columns) are to be replaced by a non-breaking space.
%    \begin{macrocode}
             local is_glue = prev_id == GLUE
             local glue_wd
             if is_glue then
                glue_wd = prev.width
             end
             local realglue = is_glue and glue_wd > 1
%    \end{macrocode}
%
% \changes{v3.3d}{2017-10-17}{In default mode, for `:’ only, check
%    if next node is a glyph or not.  If it is, turn the `auto’ flag
%    to false (avoids spurious spaces in URLs, MSDOS paths or 10:35).}
%
% \changes{v3.5s}{2024-02-28}{A `:’ followed by `-’ or a ligature
%    should not trigger spacing.}
%
%    For characters for which |FB_punct_thin| or |FB_punct_thick| is
%    \emph{true}, the amount of spacing to be typeset before them
%    is controlled by commands |\FBthinspace| and |\FBcolonspace|
%    respectively.
%    Two options: if a space has been typed in before (turned into
%    \emph{glue} in the node list), we remove the \emph{glue} and add a
%    nobreak penalty and the required \emph{glue}.
%    Otherwise (|auto| option), the penalty and the required
%    \emph{glue} are inserted if attribute |\FB@addDPspace| is set,
%    unless any of these four conditions is met:
%    a) node is `:’ and the next one is of type GLYPH (avoids spurious
%       spaces in http://mysite, C:\textbackslash{} or 10:35);
%    b) the previous character is part of type |FB_punct_null|
%       (avoids spurious spaces in strings like |(!)| or |??|);
%    c) a null glue (actually <= 1 sp for tabulars, possibly < 0)
%       preceeds the punctuation character (for tabulars and listings);
%    d) the punctuation character starts a paragraph or an |\hbox{}|.
%
%    When option \fbo{UnicodeNoBreakSpaces} is set to \fbo{true},
%    a Unicode character U+00A0 or U+202F is inserted instead of
%    penalty and glue.
%    \begin{macrocode}
             if FB_punct_thin[char] or FB_punct_thick[char] then
                local SBDP = has_attribute(item, addDPspace)
                local auto = SBDP and SBDP > 0
                if FB_punct_thick[char] and auto then
                   local next = item.next
                   local next_id
                   if next then
                      next_id = next.id
                   end
                   if next_id and
                      (next_id == GLYPH or next_id == DISC) then
                      auto = false
                   end
                end
                if auto then
                   if (prev_char and FB_punct_null[prev_char]) or
                      (is_glue and glue_wd <= 1) or
                      (prev_id == HLIST and prev_subtype == 3) or
                      (prev_id == TEMP) then
                      auto = false
                   end
                end
                local fbglue
                local t
                if FB_punct_thick[char] then
                      t = FBsp.colon.gl
                      nbspace.char = FBsp.colon.ch
                else
                      t = FBsp.thin.gl
                      nbspace.char = FBsp.thin.ch
                end
                fbglue = new_glue_scaled(fid, t)
%    \end{macrocode}
%    In case |new_glue_scaled| fails (returns |nil|) the node list
%    remains unchanged.
%    \begin{macrocode}
                if (realglue or auto) and fbglue then
                   if realglue then
                      head = remove_node(head,prev,true)
                   end
                   if (FRucsNBSP) then
                      nbspace.font = fid
                      nbspace.attr = attr
                      insert_node_before(head,item,copy_node(nbspace))
                   else
                      nobreak.attr = attr
                      fbglue.attr  = attr
                      insert_node_before(head,item,copy_node(nobreak))
                      insert_node_before(head,item,copy_node(fbglue))
                   end
                end
%    \end{macrocode}
%    Let’s consider `»’ and `›’ now (the only remaining glyphs of
%    |FB_punct_left| class): we just have to remove any \emph{glue}
%    possibly preceeding them, then to insert the nobreak penalty and
%    the proper \emph{glue} (controlled by |\FBguillspace|).
%    If either a) the preceding glyph is member of |FB_guil_null|, or
%    b) `»’/`›’ is the first glyph of an |\hbox{}| or a paragraph, nothing
%    is done, this is controlled by the |addgl| flag.
%
% \changes{v3.1a}{2014-06-18}{Added flag addgl which must also be true
%    when prev or next is not a char (i.e. \cs{kern}0 in
%    «\cs{texttt}\{a\}»).}
%
% \changes{v3.1g}{2015-06-26}{flag addgl set to false for `»’
%    at the beginning of an \cs{hbox} or a paragraph or a tabular
%    `l’ and `c’ columns.}
%
%    \begin{macrocode}
             else
                local addgl = (prev_char and
                               not FB_guil_null[prev_char])
                              or
                              (not prev_char and
                               prev_id ~= TEMP and
                               not (prev_id == HLIST and
                                    prev_subtype == 3)
                              )
%    \end{macrocode}
%    Correction for tabular `c’ (glue 0 plus 1 fil) and `l’ (glue 1sp)
%    columns:
%    \begin{macrocode}
                if is_glue and glue_wd <= 1 then
                   addgl = false
                end
                local t = FBsp.guill.gl
                nbspace.char = FBsp.guill.ch
                local fbglue = new_glue_scaled(fid, t)
                if addgl and fbglue then
                   if is_glue then
                      head = remove_node(head,prev,true)
                   end
                   if (FRucsNBSP) then
                      nbspace.font = fid
                      nbspace.attr = attr
                      insert_node_before(head,item,copy_node(nbspace))
                   else
                      nobreak.attr = attr
                      fbglue.attr  = attr
                      insert_node_before(head,item,copy_node(nobreak))
                      insert_node_before(head,item,copy_node(fbglue))
                   end
                end
             end
%    \end{macrocode}
%    Similarly, for `«’ or `‹’ (unique members of the |FB_punct_right|
%    class): unless either
%    a) the next glyph is member of |FB_guil_null|, or
%    b) `«/‹’ is the last glyph of an |\hbox{}| or a paragraph (then the
%    |addgl| flag is false, nothing is done), we remove any \emph{glue}
%    possibly following it and insert first the proper \emph{glue} then
%    a nobreak penalty so that finally the penalty preceeds the
%    \emph{glue}.
%
% \changes{v3.1a}{2014-06-18}{Look ahead when next is a kern
%    (i.e. in « \cs{texttt}\{a\} »).}
%
% \changes{v3.1g}{2015-06-26}{Flag addgl set to false for
%    `«’ at the end of an \cs{hbox} or a paragraph or when followed by
%    a null glue (i.e. springs).}
%
% \changes{v3.5o}{2022-10-11}{Opening guill.: look ahead when next is
%    a penalty (nobreak space).}
%
%    \begin{macrocode}
          elseif FB_punct_right[char] then
             local next = item.next
             local next_id, next_subtype, next_char, nextnext, kern_wd
             if next then
                next_id = next.id
                next_subtype = next.subtype
%    \end{macrocode}
%    In case of coding |«~| or |‹~| remove the penalty and the glue:
%    \begin{macrocode}
                if next_id == PENALTY then
                   nextnext = next.next
                   if nextnext and nextnext.id == GLUE then
                      head = remove_node(head,nextnext,true)
                      head = remove_node(head,next,true)
                      next = item.next
                      if next then
                         next_id = next.id
                         next_subtype = next.subtype
                         if next_id == GLYPH then
                            next_char = next.char
                         end
                     end
                   end
                end
%    \end{macrocode}
%    A |kern0| might hide a |penalty| and/or |glue|, so look ahead if
%    |next| is a kern (this occurs with |« \texttt{a} »| and
%    |«~\texttt{a}~»|):
%    \begin{macrocode}
                if next_id == KERN then
                   kern_wd = next.kern
                   if kern_wd == 0 then
                      nextnext = next.next
                      if nextnext then
                         next = nextnext
                         next_id = nextnext.id
                         next_subtype = nextnext.subtype
                         if next_id == PENALTY then
                            nextnext = next.next
                            if nextnext and nextnext.id == GLUE then
                               head = remove_node(head,next,true)
                               head = remove_node(head,nextnext,true)
                               next = item.next
                               if next then
                                  next_id = next.id
                                  next_subtype = next.subtype
                               end
                            end
                         end
                      end
                   end
                end
                if next_id == GLYPH then
                   next_char = next.char
                end
             end
             local is_glue = next_id == GLUE
             if is_glue then
                glue_wd = next.width
             end
%    \end{macrocode}
%    The |addgl| flag only depends on |next_char| and |is_glue|:
%    \begin{macrocode}
             local addgl = (next_char and not FB_guil_null[next_char])
                           or (next and not next_char)
%    \end{macrocode}
%    Correction for tabular `c’ columns.  For `r’ columns, a final
%    `«’ character needs to be coded as |\mbox{«}| for proper spacing
%    (|\NoAutoSpacing| is another option).
%    \begin{macrocode}
             if is_glue and glue_wd == 0 then
                addgl = false
             end
             local fid = item.font
             local t = FBsp.guill.gl
             nbspace.char = FBsp.guill.ch
             local fbglue = new_glue_scaled(fid, t)
             if addgl and fbglue then
                if is_glue then
                   head = remove_node(head,next,true)
                end
                if (FRucsNBSP) then
                   nbspace.font = fid
                   nbspace.attr = attr
                   insert_node_after(head, item, copy_node(nbspace))
                else
                   nobreak.attr = attr
                   fbglue.attr  = attr
                   insert_node_after(head, item, copy_node(fbglue))
                   insert_node_after(head, item, copy_node(nobreak))
                end
             end
          end
       end
    end
  end
  return head
end
%    \end{macrocode}
%
% \changes{v4.0a}{2025-06-05}{New function 'euphonic\_t' for hyphenation
%    of compound words. Suggested by Thomas Savary.}
%
%    This function deals with hyphenation of the euphonic-t in French:
%    strings like ``a-t-il’’, ``dira-t-elle’’, ``va-t-on’’,
%    ``semble-t-il’’, etc. may be hypenated on the first `-’,
%    never on the second one. It increases the hyphen penalty to 10000
%    on the second `-’.
%    \begin{macrocode}
local FB_t =
  {[0x74]             = true,
   [0x54]             = true}
local function euphonic_t (head)
  for item in node.traverse_id(DISC, head) do
    if item.subtype == 2 then
       local next = item.next
       local lang
       local nnext
       if next and next.id == GLYPH and FB_t[next.char] then
          lang = next.lang
          nnext = next.next
       end
       if lang == FR and nnext and
          nnext.id == DISC and nnext.subtype == 2 then
          nnext.penalty = 10000
       end
    end
  end
  return head
end
return french_punctuation, euphonic_t
%</lua>
%    \end{macrocode}
%    \end{environment}
%
% \changes{v3.0b}{2014-02-13}{frenchb.lua was not found by
%    Lua function dofile (not kpathsea aware).
%    Call function kpse.find\_file first, as suggested by Paul Gaborit.}
%
% \changes{v3.1g}{2015-06-17}{Lua function french\_punctuation is now
%    inserted at the end of the `kerning’ callback (no priority)
%    instead of `hpack\_filter’ and `pre\_linebreak\_filter’.}
%
%    As a language tag is part of glyph nodes in LuaTeX, no more
%    switching has to be done in |\extrasfrench|.
%
%    The next  definition will be used to activate Lua punctuation: it
%    loads \file{frenchb.lua} and adds function |french_punctuation|
%    to the |kerning| callback; "adding" anything actually disables
%    the built-in kerning for Type1 fonts (which is now added to
%    |french_punctuation|).
%    \begin{macrocode}
%<*french>
\def\activate@luacode{%
    \directlua{%
      FR = \the\l@french ;
      local path = kpse.find_file("frenchb.lua", "lua")
      if path then
         local f1, f2 = dofile(path)
         luatexbase.add_to_callback("kerning",
                    f1, "frenchb.french_punctuation")
         luatexbase.add_to_callback("pre_linebreak_filter",
                    f2, "frenchb.euphonic_t")
      else
         texio.write_nl('')
         texio.write_nl('*****************************')
         texio.write_nl('Error: frenchb.lua not found.')
         texio.write_nl('*****************************')
         texio.write_nl('')
      end
     }%
  }
%    \end{macrocode}
%
%    A new `if’ |\ifFBAutoSpacePunctuation| needs to be defined now to
%    control the two possible ways of dealing with `high punctuation’.
%    it’s default value is true, but it can be set to false by
%    \fbsetup{AutoSpacePunctuation=false} for finer control.
%    \begin{macrocode}
\newif\ifFBAutoSpacePunctuation  \FBAutoSpacePunctuationtrue
%    \end{macrocode}
%
% \begin{macro}{\AutoSpaceBeforeFDP}
% \begin{macro}{\NoAutoSpaceBeforeFDP}
%
% \changes{v2.3a}{2008-10-10}{\cs{NoAutoSpaceBeforeFDP} and
%    \cs{AutoSpaceBeforeFDP} now set the flag
%    \cs{ifFBAutoSpacePunctuation} accordingly (LaTeX only).}
%
% \changes{v2.3e}{2009-10-10}{Execute \cs{AutoSpaceBeforeFDP}
%    also in LaTeX to define \cs{FDP@colonspace}: needed for
%    tex4ht, pointed out by MPG.}
%
%    {\sloppypar |\autospace@beforeFDP| and |\noautospace@beforeFDP| are
%    internal commands.  |\autospace@beforeFDP| sets LuaTeX attribute
%    |\FB@addDPspace| to 1 (true), while |\noautospace@beforeFDP| sets
%    flag |\FB@addDPspace| to 0 (false).
%    User commands |\AutoSpaceBeforeFDP| and |\NoAutoSpaceBeforeFDP| do
%    the same and take care of the flag |\ifFBAutoSpacePunctuation| in
%    LaTeX{}.\par}
%
%    Set the default now for Plain (done later for LaTeX).
%    \begin{macrocode}
\def\autospace@beforeFDP{\FB@addDPspace=\@ne \relax}
\def\noautospace@beforeFDP{\FB@addDPspace=\z@ \relax}
\ifLaTeXe
  \def\AutoSpaceBeforeFDP{\autospace@beforeFDP
                          \FBAutoSpacePunctuationtrue}
  \def\NoAutoSpaceBeforeFDP{\noautospace@beforeFDP
                            \FBAutoSpacePunctuationfalse}
  \AtEndOfPackage{\AutoSpaceBeforeFDP}
\else
  \let\AutoSpaceBeforeFDP\autospace@beforeFDP
  \let\NoAutoSpaceBeforeFDP\noautospace@beforeFDP
  \AutoSpaceBeforeFDP
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NoAutoSpacing}
%    The following command disables automatic spacing for high
%    punctuation and French quote characters. It
%    is meant to be used inside a group.
%    |\NoAutoSpacing| must be inhibited in bookmarks. The faked
%    definition of |\texorpdfstring| will be overwritten
%    by \file{hyperref.sty}.
%
% \changes{v3.6b}{2024-06-26}{\cs{NoAutoSpacing} must be inhibited
%    in bookmarks.}
%
%    \begin{macrocode}
\providecommand\texorpdfstring[2]{#1}
\DeclareRobustCommand{\NoAutoSpacing}{%
              \texorpdfstring{\FB@spacing=\z@}{}%
}
%    \end{macrocode}
% \end{macro}
%
%  \subsection{Commands for French quotation marks}
%  \label{ssec-quotes}
%
% \begin{macro}{\guillemotleft}
% \begin{macro}{\guillemotright}
% \begin{macro}{\guilsinglleft}
% \begin{macro}{\guilsinglright}
% \begin{macro}{\textquoteddblleft}
% \begin{macro}{\textquoteddblright}
%    We provide the following definitions for non-LaTeX users only as
%    fall-back, they are welcome to change them for anything better.
%    \begin{macrocode}
\ifLaTeXe
\else
  \def\guillemotleft{{\char"00AB}}
  \def\guillemotright{{\char"00BB}}
  \def\textquotedblleft{{\char"201C}}
  \def\textquotedblright{{\char"201D}}
  \def\guilsinglleft{{\char"2029}}
  \def\guilsinglright{{\char"203A}}
  \let\xspace\relax
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\og}
% \begin{macro}{\fg}
%
%    The user level macros for quotation marks are named |\og|
%    (``\underline{o}uvrez \underline{g}uillemets’’) and |\fg|
%    (``\underline{f}ermez \underline{g}uillemets’’).
%    They are kept for backward compatibility only, as typing in « and »
%    is much easier.
%    Another option for typesetting quotes in French is to use the
%    command |\frquote| (see below).
%    If the current language is not French, |\og| and |\fg| provide
%    default (English) quotes.
%    \begin{macrocode}
\newcommand*{\og}{\textquotedblleft}
\newcommand*{\fg}{%
  \texorpdfstring{\ifdim\lastskip>\z@\unskip\fi\textquotedblright\xspace}%
                 {\textquotedblright\xspace}%
  }
%    \end{macrocode}
%
%    The definitions of |\og| and |\fg| for quotation marks are
%    switched on and off through the |\extrasfrench| |\noextrasfrench|
%    mechanism.  Outside French, |\og| and |\fg| will typeset standard
%    English opening and closing double quotes.
%    We’ll try to be smart to users of David~Carlisle’s \pkg{xspace}
%    package: if this package is loaded there will be no need for |{}|
%    or |\ | to get a space after |\fg|, otherwise |\xspace| will be
%    defined as |\relax| (done at the end of this file).
%
%    \begin{macrocode}
\newcommand*{\FB@og}{\texorpdfstring{\guillemotleft}%
                                    {\guillemotleft\space}}
\newcommand*{\FB@fg}{\texorpdfstring{\ifdim\lastskip>\z@\unskip\fi
                           \guillemotright}{\space\guillemotright}}
\def\bbl@frenchguillemets{\def\og{\FB@og}%
                          \def\fg{\FB@fg\xspace}}
\addto\extrasfrench{\babel@save\og \babel@save\fg
                    \bbl@frenchguillemets}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\frquote}
%    Another way of entering French quotes relies on |\frquote{}|
%    with supports up to two levels of quotes.
%    Let’s define the default quote characters to be used for level one
%    or two of quotes…
%
% \changes{v3.7a}{2024-08-19}{Flag \cs{ifFBcloseguill} does not apply
%    to \cs{@fgii}.}
%
% \changes{v4.1a}{2026-03-30}{\cs{AddToHook\{para-begin\}} replaces
%    \cs{everypar} in LaTeX to handle \cs{FBeverypar@quote}.}
%
%    \begin{macrocode}
\newcommand*{\@ogi}{\ifmmode\hbox{\guillemotleft}\else\guillemotleft\fi}
\newcommand*{\@fgi}{\ifmmode\hbox{\guillemotright}\else\guillemotright\fi}
\newcommand*{\ogii}{\ifFBInnerGuillSingle \guilsinglleft
                    \else                 \textquotedblleft
                    \fi}
\newcommand*{\fgii}{\ifFBInnerGuillSingle \guilsinglright
                    \else                 \textquotedblright
                    \fi}
\newcommand*{\@ogii}{\ifmmode\hbox{\ogii}\else\ogii\fi}
\newcommand*{\@fgii}{\ifmmode\hbox{\fgii}\else\fgii\fi}
%    \end{macrocode}
%    and the needed technical stuff to handle options:
%    \begin{macrocode}
\newcount\FBguill@level
\newtoks\FBold@everypar
%    \end{macrocode}
%    For PlainTeX, the definition of |\FB@addquote@everypar| is borrowed
%    from \file{csquotes.sty}.
%    \begin{macrocode}
\ifLaTeXe
  \def\FB@addquote@everypar{%
    \ifx\FBeveryparguill\FBguillnone
    \else
      \AddToHook{para/begin}[.]%
          {\box\IndentBox\FBeverypar@quote\OmitIndent}%
    \fi}
  \def\FB@removequote@everypar{%
    \ifx\FBeveryparguill\FBguillnone
    \else \RemoveFromHook{para/begin}[.]%
    \fi}
\else
  \def\FB@addquote@everypar{%
    \let\FBnew@everypar\everypar
    \FBold@everypar=\expandafter{\the\everypar}%
    \FBnew@everypar={\the\FBold@everypar\FBeverypar@quote}%
    \let\everypar\FBold@everypar
    \let\FB@addquote@everypar\relax
  }
  \let\FB@removequote@everypar\relax
\fi
\newif\ifFBcloseguill  \FBcloseguilltrue
\newif\ifFBInnerGuillSingle
\def\FBguillopen{\guillemotleft}
\def\FBguillclose{\guillemotright}
\let\FBguillnone\empty
\let\FBeveryparguill\FBguillopen
\let\FBeverylineguill\FBguillnone
\let\FBeverypar@quote\relax
\let\FBeveryline@quote\empty
%    \end{macrocode}
%
%    The main command |\frquote| accepts (in LaTeX2e only) a starred
%    version which suppresses the closing quote; it is meant to be used
%    for inner quotations which end together with the outer one, then
%    only one closing guillemet (the outer one) should be printed.
%    |\frquote| (without star) is now designed to work in bookmarks too.
%    \begin{macrocode}
\ifLaTeXe
  \DeclareRobustCommand\frquote{%
    \texorpdfstring{\@ifstar{\FBcloseguillfalse\fr@quote}%
                            {\FBcloseguilltrue \fr@quote}}%
                   {\bm@fr@quote}%
  }
  \newcommand{\bm@fr@quote}[1]{« #1 »}
\else
  \newcommand\frquote[1]{\fr@quote{#1}}
\fi
%    \end{macrocode}
%
%    The internal command |\fr@quote| takes one (long) argument: the
%    quotation text.
%    \begin{macrocode}
\newcommand{\fr@quote}[1]{%
  \leavevmode
  \advance\FBguill@level by \@ne
  \ifcase\FBguill@level
  \or
%    \end{macrocode}
%    This for level 1 (outer) quotations: set |\FBeverypar@quote|
%    for level 1 quotations and add it at each paragraph start using
%    |\FB@addquote@everypar|, then print the quotation:
%    \begin{macrocode}
    \ifx\FBeveryparguill\FBguillnone
      \let\FBeverypar@quote\relax
    \else
      \def\FBeverypar@quote{\FBeveryparguill}%
      \FB@addquote@everypar
    \fi
    \@ogi #1\@fgi
  \or
%    \end{macrocode}
%    This for level 2 (inner) quotations: Omega’s command
%    |\localleftbox| included in LuaTeX, is convenient for repeating
%    guillemets at the beginning of every line.\hlabel{cs:localleftbox}
%    \begin{macrocode}
    \ifx\FBeverylineguill\FBguillopen
      \def\FBeveryline@quote{\guillemotleft\FBguillspace}%
      \localleftbox{\FBeveryline@quote}%
      \let\FBeverypar@quote\relax
      \@ogi #1\ifFBcloseguill\@fgi\fi
    \else
      \ifx\FBeverylineguill\FBguillclose
        \def\FBeveryline@quote{\guillemotright\FBguillspace}%
        \localleftbox{\FBeveryline@quote}%
        \let\FBeverypar@quote\relax
        \@ogi #1\ifFBcloseguill\@fgi\fi
      \else
%    \end{macrocode}
%    otherwise we eventually need to redefine |\FBeverypar@quote|
%    for level 2 quotations:
%    \begin{macrocode}
        \let\FBeverypar@quote\relax
        \ifFBInnerGuillSingle
          \ifx\FBeveryparguill\FBguillopen
            \def\FBeverypar@quote{\guilsinglleft\FBguillspace}%
          \fi
          \ifx\FBeveryparguill\FBguillclose
            \def\FBeverypar@quote{\guilsinglright\FBguillspace}%
          \fi
        \fi
        \@ogii #1\@fgii
      \fi
    \fi
  \else
%    \end{macrocode}
%    Warn if |\FBguill@level| >~2:
%    \begin{macrocode}
    \ifx\PackageWarning\@undefined
      \fb@warning{\noexpand\frquote\space handles up to
                  two levels.\\ Quotation not printed.}%
    \else
      \PackageWarning{french.ldf}{%
         \protect\frquote\space handles up to two levels.
         \MessageBreak Quotation not printed.  Reported}
    \fi
  \fi
%    \end{macrocode}
%
%    Closing: step down |\FBguill@level| and clean on exit.
%    Changes made global in case |\frquote{}| ends inside an
%    environment.
%    \begin{macrocode}
  \global\advance\FBguill@level by \m@ne
  \ifcase\FBguill@level \global\let\FBeverypar@quote\relax
      \FB@removequote@everypar
  \or \gdef\FBeverypar@quote{\FBeveryparguill}%
      \global\let\FBeveryline@quote\empty
      \ifx\FBeverylineguill\FBguillnone\else\localleftbox{}\fi
  \fi
}
%    \end{macrocode}
%
%    The next command is intended to be used in list environments to
%    suppress quotes which might be added by |\FBeverypar@quote| after
%    items for instance.
%    \begin{macrocode}
\newcommand*{\NoEveryParQuote}{%
  \let\FBeveryparguill\FBguillnone
  \let\FBeverypar@quote\relax
}
%    \end{macrocode}
% \end{macro}
%
%  \subsection{Date in French}
% \label{sssec-date}
%
% \begin{macro}{\frenchtoday}
% \begin{macro}{\frenchdate}
% \begin{macro}{\datefrench}
%    The following code creates a macro |\datefrench| which in turn
%    defines command |\frenchtoday| (|\today| is defined as
%    |\frenchtoday| in French).
%    This new implementation relies on commands |\SetString| and
%    |\SetStringLoop|, therefore requires \babel~3.10 or newer.
%
%    \begin{macrocode}
\StartBabelCommands*{french}{date}
    [unicode, fontenc=TU EU1 EU2, charset=utf8]
    \SetStringLoop{month#1name}{%
      janvier,février,mars,avril,mai,juin,juillet,%
      août,septembre,octobre,novembre,décembre}
    \SetString\today{\FB@date{\year}{\month}{\day}}
\EndBabelCommands
%    \end{macrocode}
%    |\frenchdate| (which produces an unbreakable string) and
%    |\frenchtoday| (breakable) both rely on |\FB@date|, the inner
%    group is needed for |\hbox|.
%    \begin{macrocode}
\newcommand*{\FB@date}[3]{%
  {{\number#3}\ifnum1=#3{\ier}\fi\FBdatespace
  \csname month\romannumeral#2name\endcsname
  \ifx#1\@empty\else\FBdatespace\number#1\fi}}
\newcommand*{\FBdatebox}{\hbox}
\newcommand*{\FBdatespace}{\space}
\newcommand*{\frenchdate}{\FBdatebox\FB@date}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%  \subsection{Extra utilities}
%
%    Let’s provide the French user with some extra utilities.
%
% \begin{macro}{\up}
% \begin{macro}{\fup}
%
%    |\up| eases the typesetting of superscripts like `1\up{er}’.
%
%    When a font has built-in superscripts, the best thing to do is
%     to just use them, otherwise |\fup| provides an alternative which
%    typsesets superscripts slightly smaller and higher.  Scaling is
%    done using package \pkg{scalefnt} which will be loaded at the end
%    of \babel’s loading (\frenchb{} being an option of \babel, it
%    cannot load a package while being read).
%
%    Options \fbo{FrenchSuperscripts} and \fbo{LowercaseSuperscripts}
%    will be processed in\\ |\FBprocess@options| to choose which version
%    of |\up{}| will be used in the document.
%    \begin{macrocode}
\newif\ifFBFrenchSuperscripts       \FBFrenchSuperscriptstrue
\newif\ifFBLowercaseSuperscripts    \FBLowercaseSuperscriptstrue
\newdimen\FB@Mht
\ifLaTeXe
  \AtEndOfPackage{\RequirePackage{scalefnt}}
%    \end{macrocode}
%    |\fup| holds the definition of fake superscripts.
%    The scaling ratio is 0.65, raising is computed to put the top of
%    lower case letters (like `m’) just under the top  of upper case
%    letters (like `M’), precisely 12\% down.  These settings
%    look correct for most fonts, but can be tuned by the end-user
%    if necessary by changing |\FBsupR| and |\FBsupS| commands.
%
%    |\FB@lc| is defines as |\MakeLowercase| to inhibit the uppercasing
%    of superscripts (this may happen in page headers with the standard
%    classes but is wrong); |\FB@lc| can be redefined to do nothing using
%    option \fbo{LowercaseSuperscripts=false} of \fbsetup{}.
%    \begin{macrocode}
  \newcommand*{\FBsupR}{-0.12}
  \newcommand*{\FBsupS}{0.65}
  \newcommand*{\FB@lc}[1]{\MakeLowercase{#1}}
  \NewDocumentCommand\fup{ m }{%
    \settoheight{\FB@Mht}{M}%
    \addtolength{\FB@Mht}{\FBsupR \FB@Mht}%
    \addtolength{\FB@Mht}{-\FBsupS ex}%
    \raisebox{\FB@Mht}{\scalefont{\FBsupS}{\FB@lc{#1}}}%
    }
%    \end{macrocode}
%    Poor man’s definition of |\up| for Plain.
%    \begin{macrocode}
\else
  \providecommand*{\up}[1]{\leavevmode\raise1ex\hbox{\sevenrm #1}}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ieme}
% \begin{macro}{\ier}
% \begin{macro}{\iere}
% \begin{macro}{\iemes}
% \begin{macro}{\iers}
% \begin{macro}{\ieres}
%
%    Some handy macros for those who don’t know how to abbreviate
%    ordinals:
%    \begin{macrocode}
\def\ieme{\up{e}\xspace}
\def\iemes{\up{es}\xspace}
\def\ier{\up{er}\xspace}
\def\iers{\up{ers}\xspace}
\def\iere{\up{re}\xspace}
\def\ieres{\up{res}\xspace}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FBmedkern}
% \begin{macro}{\FBthickkern}
%    Configurable kerns \cs{FBmedkern}, and \cs{FBthickkern}
%    suitable for HTML translation.
%    \begin{macrocode}
\newcommand*{\FBmedkern}{\kern+.2em}
\newcommand*{\FBthickkern}{\kern+.3em}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\primo}
% \begin{macro}{\fprimo)}
% \begin{macro}{\nos}
% \begin{macro}{\Nos}
% \begin{macro}{\No}
% \begin{macro}{\no}
%    Some support macros relying on |\up| for numbering, safe in
%    bookmarks:
%    \begin{macrocode}
\newcommand*{\FrenchEnumerate}[1]{%
     #1\texorpdfstring{\up{o}\FBthickkern}{\textdegree\space}}
\newcommand*{\FrenchPopularEnumerate}[1]{%
     #1\texorpdfstring{\up{o})\FBthickkern}{\textdegree\space}}
%    \end{macrocode}
%
%    Typing |\primo| should result in `\up{o}\kern+.3em’ (except in
%    bookmarks where |\textdegree| is used instead of o-superior),
%    \begin{macrocode}
\def\primo{\FrenchEnumerate1}
\def\secundo{\FrenchEnumerate2}
\def\tertio{\FrenchEnumerate3}
\def\quarto{\FrenchEnumerate4}
%    \end{macrocode}
%    while typing |\fprimo)| gives `\up{o})\kern+.3em (except in
%     bookmarks where |\textdegree| is used instead),.
%    \begin{macrocode}
\def\fprimo){\FrenchPopularEnumerate1}
\def\fsecundo){\FrenchPopularEnumerate2}
\def\ftertio){\FrenchPopularEnumerate3}
\def\fquarto){\FrenchPopularEnumerate4}
%    \end{macrocode}
%
%    Let’s provide four macros for the common abbreviations
%    of ``Numéro’’. In bookmarks ° is used instead of o-superior.
%    \begin{macrocode}
\DeclareRobustCommand*{\No}{%
    \texorpdfstring{N\up{o}\FBmedkern}{N\textdegree\space}}
\DeclareRobustCommand*{\no}{%
    \texorpdfstring{n\up{o}\FBmedkern}{n\textdegree\space}}
\DeclareRobustCommand*{\Nos}{%
    \texorpdfstring{N\up{os}\FBmedkern}{N\textdegree\space}}
\DeclareRobustCommand*{\nos}{%
    \texorpdfstring{n\up{os}\FBmedkern}{n\textdegree\space}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bname}
% \begin{macro}{\bsc}
%    These commands are meant to easily enter family names (in small
%    capitals for the latter) while avoidind hyphenation.
%    A |\kern0pt| is used instead of |\mbox| because |\mbox| would break
%    microtype’s font expansion; as a positive side effect, composed
%    names (such as Dupont-Durand) can now be hyphenated on explicit
%    hyphens.
%
% \changes{v3.5k}{2020-07-18}{\cs{bsc} now relies on
%    \cs{texorpdfstring} to be safe in bookmarks.}
%
%    \begin{macrocode}
\ifLaTeXe
  \DeclareRobustCommand*{\bname}[1]{%
    \texorpdfstring{\leavevmode\begingroup\kern0pt #1\endgroup}{#1}%
  }
  \DeclareRobustCommand*{\bsc}[1]{%
    \texorpdfstring{\leavevmode\begingroup\kern0pt \scshape #1\endgroup}%
                   {\textsc{#1}}%
  }
\else
  \newcommand*{\bname}[1]{\leavevmode\begingroup\kern0pt #1\endgroup}
  \let\bsc\bname
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    Some definitions for special characters.  We won’t define |\tilde|
%    as a Text Symbol not to conflict with the macro |\tilde| for math
%    mode and use the name |\tild| instead.  Note that |\boi| may
%    \emph{not} be used in math mode, its name in math mode is
%    |\backslash|.
%
%    \begin{macrocode}
\providecommand*{\textbackslash}{{\char"005C}}
\providecommand*{\textasciicircum}{{\char"005E}}
\providecommand*{\textasciitilde}{{\char"007E}}
\providecommand*{\degre}{°}
\providecommand*{\degres}{°}
\providecommand*{\boi}{\textbackslash}
\providecommand*{\circonflexe}{\textasciicircum}
\providecommand*{\tild}{\textasciitilde}
\providecommand*{\at}{@}
%    \end{macrocode}
%
%  \subsection{Formatting numbers}
%  \label{ssec-numbers}
%
% \begin{macro}{\StandardMathComma}
% \begin{macro}{\DecimalMathComma}
%    As mentioned in the \TeX{}book p.~134, the comma is of type
%    |\mathpunct| in math mode: it is automatically followed by a
%    thin space.  This is convenient in lists and intervals but
%    unpleasant when the comma is used as a decimal separator
%    in French: it has to be entered as |{,}|.
%    |\DecimalMathComma| makes the comma be an ordinary character
%    (of type |\mathord|) in French \emph{only} (no space added);
%    |\StandardMathComma| switches back to the standard behaviour
%    of the comma.
%
% \changes{v3.5p}{2023-01-02}{\cs{DecimalMathComma} can again be
%    used in the preamble for a global action.  It now works as
%    expected inside a group.}
%
%    Unfortunately, |\newcount| inside |\if| breaks Plain formats.
%    \begin{macrocode}
\newif\ifFB@icomma
\newcount\mc@charclass
\newcount\mc@charfam
\newcount\mc@charslot
\newcount\std@mcc
\newcount\dec@mcc
  \mc@charclass=\Umathcharclass`\,
  \newcommand*{\dec@math@comma}{%
    \mc@charfam=\Umathcharfam`\,
    \mc@charslot=\Umathcharslot`\,
    \Umathcode`\,= 0 \mc@charfam \mc@charslot
  }
  \newcommand*{\std@math@comma}{%
    \mc@charfam=\Umathcharfam`\,
    \mc@charslot=\Umathcharslot`\,
    \Umathcode`\,= \mc@charclass \mc@charfam \mc@charslot
  }
\let\dec@m@c\relax
%    \end{macrocode}
%    If |\DecimalMathComma| is issued in the document body
%    (when the current language is French) its effect will
%    survive to a language switch, unless issued inside a group
%    (see |\dec@m@c|’s expansion).
%    The \pkg{icomma} inhibits |\DecimalMathComma|.
%    \begin{macrocode}
\newif\if@FBpreamble
\ifLaTeXe \@FBpreambletrue \fi
\newif\if@preamble@DecimalMathComma
\newcommand*{\DecimalMathComma}{%
  \if@FBpreamble \@preamble@DecimalMathCommatrue
  \else
    \ifFB@icomma
      \PackageWarning{french.ldf}{%
        icomma package loaded, \protect\DecimalMathComma\MessageBreak
        does nothing.  Reported}%
    \else
      \ifFBfrench
        \dec@math@comma
        \let\dec@m@c\dec@math@comma
        \expandafter\addto\csname extras\languagename\endcsname
          {\dec@m@c}%
      \fi
    \fi
  \fi
}
\newcommand*{\StandardMathComma}{%
  \ifFB@icomma
    \PackageWarning{french.ldf}{%
      icomma package loaded, \protect\StandardMathComma\MessageBreak
      does nothing.  Reported}%
  \else
    \ifFBfrench
      \std@math@comma
      \let\dec@m@c\relax
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    This is for Plain formats \emph{only} (see below).
%    \begin{macrocode}
\ifLaTeXe\else
  \addto\noextrasfrench{\std@math@comma}
\fi
%    \end{macrocode}
%
%    Fake command |\nombre| for Plain based formats, warning users of
%    \frenchb{} v.~1.x.\ about the change:
%    \begin{macrocode}
\newcommand*{\nombre}[1]{{#1}\fb@warning{*** \noexpand\nombre
                               no longer formats numbers\string! ***}}
%    \end{macrocode}
%
%    Let’s activate LuaTeX punctuation if necessary (LaTeX or Plain)
%    so that |\FBsetspaces| commands can be used in the preamble,
%    then cleanup and exit without loading any \file{.cfg} file
%    in case of Plain formats.
%
%    \begin{macrocode}
\activate@luacode
\let\FBstop@here\relax
\def\FBclean@on@exit{%
  \let\ifLaTeXe\iffalse
  \let\LaTeXetrue\undefined
  \let\LaTeXefalse\undefined
  \let\FB@llc\loadlocalcfg
  \let\loadlocalcfg\@gobble}
\ifx\magnification\@undefined
\else
  \def\FBstop@here{%
    \FBclean@on@exit
    \ldf@finish\CurrentOption
    \let\loadlocalcfg\FB@llc
    \endinput}
\fi
\FBstop@here
%    \end{macrocode}
%
%    What follows is for LaTeX2e \emph{only}: the next piece of  code
%    would break Plain formats.
%    If issued in the preamble, |\DecimalMathComma| works globally on
%    all parts of the document that are typeset in French.
%    Can be canceled anytime by |\StandardMathComma|.
%    \begin{macrocode}
\AddToHookNext{env/document/before}{%
  \@FBpreamblefalse
  \IfPackageLoadedTF{icomma}%
     {\FB@icommatrue
      \if@preamble@DecimalMathComma
        \FBWarning{icomma package loaded, \protect\DecimalMathComma%
                   \MessageBreak does nothing.  Reported}%
      \fi
     }%
     {\if@preamble@DecimalMathComma
        \ifFB@mainlanguage@FR \dec@math@comma \fi
        \let\dec@m@c\dec@math@comma
        \addto\extrasfrench{\dec@m@c}%
      \fi
%    \end{macrocode}
%    The comma is reset to type |\mathpunct| when leaving French
%    (only if the icomma package is not loaded).
%    \begin{macrocode}
      \addto\noextrasfrench{\std@math@comma}%
     }%
  }
%    \end{macrocode}
%
% \begin{macro}{nombre}
%   We redefine |\nombre| for LaTeX2e.  The command |\nombre| is now
%   borrowed from \file{numprint.sty} for LaTeX2e.  There is no point to
%   maintain the former tricky code when a package is dedicated to do
%   the same job and more.  A warning is issued at the first call of
%   |\nombre| if |\numprint| is not defined, suggesting what to do.
%   The package \pkg{numprint} is \emph{not} loaded automatically by
%   \frenchb{} because of possible options conflict.
%
%    \begin{macrocode}
\renewcommand*{\nombre}[1]{\Warning@nombre{#1}}
\newcommand*{\Warning@nombre}[1]{%
   \ifdefined\numprint
     \numprint{#1}%
   \else
     \FBWarning{%
        \protect\nombre\space now relies on package numprint.sty,%
        \MessageBreak add \protect
        \usepackage[autolanguage]{numprint},\MessageBreak
        see file numprint.pdf for more options.\MessageBreak
        \protect\nombre\space called}%
     \global\let\Warning@nombre\relax
     {#1}%
   \fi
}
%    \end{macrocode}
% \end{macro}
%
% \changes{v3.3c}{2017-08-10}{New command \cs{FBthousandsep} to
%    customise numprint.}
%
% \changes{v3.4a}{2017-12-29}{Shrink/stretch removed in
%    \cs{FBthousandsep}.}
%
%    \begin{macrocode}
\newcommand*{\FBthousandsep}{\kern \fontdimen2\font \relax}
%    \end{macrocode}
%
%  \subsection{Caption names}
%  \label{ssec-captions-name}
%
%    The next step consists in defining the French equivalents for
%    the LaTeX caption names.
%
%    New implementation for caption names (requires \babel’s~3.10 or
%    newer).
%    \begin{macrocode}
\StartBabelCommands*{french}{captions}
      [unicode, fontenc=TU EU1 EU2, charset=utf8]
   \SetString{\refname}{Références}
   \SetString{\abstractname}{Résumé}
   \SetString{\bibname}{Bibliographie}
   \SetString{\chaptername}{Chapitre}
   \SetString{\prefacename}{Préface}
   \SetString{\appendixname}{Annexe}
   \SetString{\contentsname}{Table des matières}
   \SetString{\listfigurename}{Table des figures}
   \SetString{\listtablename}{Liste des tableaux}
   \SetString{\indexname}{Index}
   \SetString{\glossaryname}{Glossaire}
   \SetString{\figurename}{Figure}
   \SetString{\tablename}{Table}
   \SetString{\pagename}{page}
   \SetString{\seename}{voir}
   \SetString{\alsoname}{voir aussi}
   \SetString{\enclname}{P.~J. }
   \SetString{\ccname}{Copie à }
   \SetString{\headtoname}{}
   \SetString{\proofname}{Démonstration}
   \SetString{\partnameord}{partie}
   \SetString{\partfirst}{Première}
   \SetString{\partsecond}{Deuxième}
%    \end{macrocode}
%   When \fbo{PartNameFull=true} (default), |\part{}| is printed in
%   French as ``Première partie’’ instead of ``Partie I’’.
%   As logic is prohibited inside |\SetString|, let’s hide the test
%   about \fbo{PartNameFull} in |\FB@partname|.
%    \begin{macrocode}
  \SetStringLoop{ordinal#1}{%
     \frenchpartfirst,\frenchpartsecond,Troisième,Quatrième,%
     Cinquième,Sixième,Septième,Huitième,Neuvième,Dixième,Onzième,%
     Douzième,Treizième,Quatorzième,Quinzième,Seizième,%
     Dix-septième,Dix-huitième,Dix-neuvième,Vingtième}
   \AfterBabelCommands{%
     \NewDocumentCommand\FB@emptypart{}{\def\thepart{\unskip}}%
     \NewDocumentCommand\FB@partname{}{%
        \ifFBPartNameFull
          \csname ordinal\romannumeral\value{part}\endcsname\space
          \partnameord\FB@emptypart
        \else
          Partie%
        \fi}%
    }
   \SetString{\partname}{\FB@partname}
\EndBabelCommands
%    \end{macrocode}
%
%    |\figurename| and |\tablename| are printed in small caps in French,
%    unless either \fbo{SmallCapsFigTabCaptions} is set to \fbo{false}
%    or a class or package loaded before \frenchb{} defines
%    |\FBfigtabshape| as |\relax|.
%    \begin{macrocode}
\providecommand*{\FBfigtabshape}{\scshape}
%    \end{macrocode}
%
% \changes{v4.0a}{2025-05-23}{New customisation for the Part entries in
%    the toc.  Suggested by Julien Labbé.}
%
% \begin{macro}{\FBtocpartsep}
%    New command |\FBtocpartname| to help printing ``Première partie’’
%    instead of ``Partie I’’ in the Table of Contents.
%    It takes a Roman numeral as argument (the part number), and returns
%    a formatted string (``Première partie’’ if the argument is ``I’’),
%    unless option \opt{TocPartNameFull} is set to false.
%    It is used currently used only with the \cls{memoir} and
%    koma-script classes.
%
%    \begin{macrocode}
\ExplSyntaxOn
\NewExpandableDocumentCommand\FBlower{m}
 {
  \str_lowercase:n {#1}
 }
\ExplSyntaxOff
\newcommand*\FBtocpartsep{\protect\space}
\NewDocumentCommand\FBtocpartname{m}{%
    \ifFBTocPartNameFull
      \csname ordinal\FBlower{#1}\endcsname\space
           \partnameord \FBtocpartsep
    \else
      Partie%
    \fi}%
%    \end{macrocode}
% \end{macro}
%
%\subsection{Checks about packages’ loading order}
%  \label{ssec-loading-order}
%
% \begin{macro}{\FBWarning}
%    |\FBWarning| is an alias of |\PackageWarning{french.ldf}| which
%    can be made silent by option \fbo{SuppressWarning}.
%    \begin{macrocode}
\newcommand{\FBWarning}[1]{\PackageWarning{french.ldf}{#1}}
%    \end{macrocode}
% \end{macro}
%
%    Package \pkg{beamerarticle} should be loaded before \frenchb{}
%    to avoid list’s conflicts, see p.~\pageref{beamerarticle}.
%
%    \begin{macrocode}
\newif\if@FBwarning@beamerarticle
\IfPackageLoadedTF{beamerarticle}{}{\@FBwarning@beamerarticletrue}
\AddToHookNext{env/document/before}{%
   \if@FBwarning@beamerarticle
     \IfPackageLoadedTF{beamerarticle}{}%
                                     {\@FBwarning@beamerarticlefalse}%
   \fi
   \if@FBwarning@beamerarticle
     \FBWarning{Please load the "beamerarticle" package\MessageBreak
                BEFORE babel/french; reported}%
   \fi
}
%    \end{macrocode}
%
%  \subsection{Setup options: key/value stuff (l3keys)}
%  \label{ssec-keyval}
%
%    Check LaTeX2e version (support for \pkg{l3keys} required).
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
%    \end{macrocode}
%
%    All setup options are handled by command \fbsetup{} based on
%    the \file{l3keys}’ |\SetKeys{}| command.  A list of flags is
%    defined beforehand and set to default values which will possibly
%    be changed `AtEndOfPackage’ in case French is the main language.
%    After this, \fbsetup{} eventually modifies the preset values of
%    these flags.
%
% \changes{v4.0a}{2025-05-20}{Removed obsolete compatibility options
%    GlobalLayoutFrench, ListOldLayout, OldFigTabCaption}
%
% \changes{v4.0a}{2025-05-20}{Option CustomiseFigTabCaptions is set to
%    false.}
%
% \changes{v4.0a}{2025-05-20}{Options og and fg are now useless.}
%
%    Some options processing occurs in \fbsetup{},
%    \emph{only for options explicitly set} by \fbsetup{}, the rest is
%    done just before |\begin{document}|.
%
%    We first define a collection of conditionals for global layout.
%    Their defaults values are chosen so that \frenchb{} does not
%    change anything regarding the global layout.  Some of them will
%    toggled `AtEndofPackage’ according to the main language, then they
%    will all be checked again just before |\begin{document}| in
%    |\FBprocess@options| to fit |\frenchsetup{}| specifications and
%    changes required by packages loaded after \babel.
%
%    \begin{macrocode}
\newif\ifFBShowOptions
\newif\ifFBStandardLayout           \FBStandardLayouttrue
\newif\ifFBStandardListSpacing      \FBStandardListSpacingtrue
\newif\ifFBListItemsAsPar
\newif\ifFBNosepItemize             \FBNosepItemizetrue
\newif\ifFBNosepEnumerate
\newif\ifFBStandardItemizeEnv       \FBStandardItemizeEnvtrue
\newif\ifFBStandardEnumerateEnv     \FBStandardEnumerateEnvtrue
\newif\ifFBStandardItemLabels       \FBStandardItemLabelstrue
\newif\ifFBStandardLists            \FBStandardListstrue
\newif\ifFBIndentFirst
\newif\ifFBFrenchFootnotes
\newif\ifFBAutoSpaceFootnotes
\newif\ifFBOriginalTypewriter
\newif\ifFBThinColonSpace
\newif\ifFBThinSpaceInFrenchNumbers
\newif\ifFBUnicodeNoBreakSpaces
\newif\ifFBINGuillSpace
\newif\ifFBPartNameFull
\newif\ifFBTocPartNameFull
\newif\ifFBSmallCapsFigTabCaptions
\newif\ifFBCustomiseFigTabCaptions
\newif\ifFBSuppressWarning
%    \end{macrocode}
%
% \changes{v4.0b}{2025-07-02}{New \cs{ifFBnewlists} and
%    \cs{ifFBnewfootnotes} to handle the new corresponding templates.}
%
%    If the new templates for lists and footnotes are available,
%    \frenchb{} will use them as far as possible.
%    \begin{macrocode}
\newif\ifFBnewlists
\newif\ifFBnewfootnotes
\IfDocumentMetadataTF
  {\IfFormatAtLeastTF{2026-06-01}%
     {\FBnewliststrue}%
     {\def\warning@FBLaTeXFormat{%
        \FBWarning{%
         LaTeX Format 2026-06-01 is required for lists.\MessageBreak
         Please update your LaTeX distribution\MessageBreak
         or remove the \protect\DocumentMetadata{} command.\MessageBreak
         Otherwise babel-french will NOT customise lists.\MessageBreak
         Reported}%
        }%
     }%
   \FBnewfootnotestrue
  }{}
%    \end{macrocode}
%
%    Some specific code for the koma-script classes.
%    \begin{macrocode}
\newif\ifFB@koma
\ifLaTeXe
  \IfClassLoadedTF{scrartcl}{\FB@komatrue}{}
  \IfClassLoadedTF{scrbook}{\FB@komatrue}{}
  \IfClassLoadedTF{scrreprt}{\FB@komatrue}{}
\fi
\ifFB@koma
  \ifdefined\partformat
    \def\FB@partformat@fix{%
           \ifFBPartNameFull
             \babel@save\partformat
             \renewcommand*{\partformat}{\partname}%
           \fi}
    \addto\extrasfrench{\FB@partformat@fix}%
  \fi
\fi
%    \end{macrocode}
%
% \changes{v3.0c}{2014-03-30}{No list customisation when beamer
%    class is loaded.}
%
% \changes{v3.2g}{2017-01-30}{Minimal list customisation when
%    beamerarticle.sty is loaded.}
%
%    Some of the flags must be toogled when French is the main
%    language.  The latter (last option of \babel, stored in
%    |\bbl@main@language|) will be known `AtEndOfPackage’.
%    So we postpone the |\bbl@main@language| check until then.
%
%    Our list customisation conflicts with the \cls{beamer} class and
%    with the \pkg{beamerarticle} package.  The patch provided in
%    \pkg{beamerbasecompatibility} solves the conflict except in case
%    of language changes, so we provide our own patch.
%    When the \cls{beamer} is loaded, lists are not customised at all
%    to ensure compatibility.\hlabel{beamerarticle}
%    The \pkg{beamerarticle} package needs to be loaded \emph{before}
%    \babel, a warning is issued otherwise, see
%    section~\ref{ssec-loading-order}; a light customisation is
%    compatible with the \pkg{beamerarticle} package.
%
%    \begin{macrocode}
\def\FB@french{french}
\newif\ifFB@mainlanguage@FR
\AtEndOfPackage{%
  \ifx\bbl@main@language\FB@french \FB@mainlanguage@FRtrue \fi
  \ifFB@mainlanguage@FR
%    \end{macrocode}
%    \cls{beamer} requires special tuning for legacy lists:
%    \begin{macrocode}
    \ifFBnewlists
      \FBStandardListSpacingfalse
      \FBStandardItemizeEnvfalse
      \FBStandardEnumerateEnvfalse
      \FBStandardItemLabelsfalse
    \else
      \IfClassLoadedTF{beamer}%
        {\PackageInfo{french.ldf}{%
         No list customisation for the beamer class,%
         \MessageBreak reported}%
        }%
        {\IfPackageLoadedTF{beamerarticle}%
           {\FBStandardItemLabelsfalse
            \FBStandardListSpacingfalse
            \PackageInfo{french.ldf}{%
              Minimal list customisation for the beamerarticle%
              \MessageBreak package; reported}%
           }%
%    \end{macrocode}
%    Otherwise customise lists ``à la française’’:
%    \begin{macrocode}
           {\FBStandardListSpacingfalse
            \FBStandardItemizeEnvfalse
            \FBStandardEnumerateEnvfalse
            \FBStandardItemLabelsfalse
           }%
        }
    \fi
    \FBIndentFirsttrue
    \FBFrenchFootnotestrue
    \FBAutoSpaceFootnotestrue
    \FBPartNameFulltrue
    \FBTocPartNameFulltrue
    \FBStandardLayouttrue
    \FBSmallCapsFigTabCaptionstrue
  \fi
}
%    \end{macrocode}
%
% \begin{macro}{\frenchsetup}
%    Let’s define the keys to be used in \fbsetup{}.
%    \begin{macrocode}
\DeclareKeys[FBsetup]
  {
    ShowOptions.if               = FBShowOptions                        ,
    StandardLayout.default:n     = {true}                               ,
    StandardLayout.code          = \FBStandardLayout@setup{#1}          ,
    StandardListSpacing.if       = FBStandardListSpacing                ,
    ReduceListSpacing.ifnot      = FBStandardListSpacing                ,
    NosepItemize.if              = FBNosepItemize                       ,
    NosepItemize.default:n       = {true}                               ,
    NosepItemize.code            = \FBNosepItemize@setup{#1}            ,
    NosepEnumerate.if            = FBNosepEnumerate                     ,
    NosepEnumerate.code          = \FBNosepEnumerate@setup{#1}          ,
    StandardItemizeEnv.if        = FBStandardItemizeEnv                 ,
    StandardEnumerateEnv.if      = FBStandardEnumerateEnv               ,
    StandardItemLabels.if        = FBStandardItemLabels                 ,
    ItemLabels.store             = \FrenchLabelItem                     ,
    ItemLabeli.store             = \Frlabelitemi                        ,
    ItemLabelii.store            = \Frlabelitemii                       ,
    ItemLabeliii.store           = \Frlabelitemiii                      ,
    ItemLabeliv.store            = \Frlabelitemiv                       ,
    StandardLists.default:n      = {true}                               ,
    StandardLists.code           = \FBStandardLists@setup{#1}           ,
    ListItemsAsPar.if            = FBListItemsAsPar                     ,
    IndentFirst.if               = FBIndentFirst                        ,
    FrenchFootnotes.if           = FBFrenchFootnotes                    ,
    AutoSpaceFootnotes.if        = FBAutoSpaceFootnotes                 ,
    AutoSpacePunctuation.if      = FBAutoSpacePunctuation               ,
    OriginalTypewriter.if        = FBOriginalTypewriter                 ,
    ThinColonSpace.default:n     = {true}                               ,
    ThinColonSpace.code          = \FBThinColonSpace@setup{#1}          ,
    ThinSpaceInFrenchNumbers.if  = FBThinSpaceInFrenchNumbers           ,
    UnicodeNoBreakSpaces.if      = FBUnicodeNoBreakSpaces               ,
    FrenchSuperscripts.if        = FBFrenchSuperscripts                 ,
    LowercaseSuperscripts.if     = FBLowercaseSuperscripts              ,
    PartNameFull.if              = FBPartNameFull                       ,
    TocPartNameFull.if           = FBTocPartNameFull                    ,
    CustomiseFigTabCaptions.default:n = {true}                          ,
    CustomiseFigTabCaptions.code = \FBCustomiseFigTabCaptions@setup{#1} ,
    SmallCapsFigTabCaptions.default:n = {true}                          ,
    SmallCapsFigTabCaptions.code = \FBSmallCapsFigTabCaptions@setup{#1} ,
    SuppressWarning.default:n    = {true}                               ,
    SuppressWarning.code         = \FBSuppressWarning@setup{#1}         ,
    INGuillSpace.default:n       = {true}                               ,
    INGuillSpace.code            = \FBINGuillSpace@setup{#1}            ,
    InnerGuillSingle.if          = FBInnerGuillSingle                   ,
    EveryParGuill.default:n      = {open}                               ,
    EveryParGuill.code           = \FBEveryParGuill@setup{#1}           ,
    EveryLineGuill.default:n     = {open}                               ,
    EveryLineGuill.code          = \FBEveryLineGuill@setup{#1}          ,
    og.code                      = \FBog@setup{#1}                      ,
    fg.code                      = \FBfg@setup{#1}                      ,
}
%    \end{macrocode}
%
%    Let’s now define this command which reads and sets the options
%    to be processed either immediately (i.e.\ just after setting the
%    key) or just before |\begin{document}|)by |\FBprocess@options|.
%    \fbsetup{} can only be called in the preamble.
%
%    \begin{macrocode}
\newcommand*{\frenchsetup}[1]{%
  \SetKeys[FBsetup]{#1}%
}%
\@onlypreamble\frenchsetup
%    \end{macrocode}
%    Keep the former name |\frenchbsetup| working for compatibility.
%    \begin{macrocode}
\let\frenchbsetup\frenchsetup
\@onlypreamble\frenchbsetup
%    \end{macrocode}
%
%    The following commands, defined with property |.code| in
%    |DeclareKeys{}|, execute some post-treatment required to
%    immediately take the flags value into account.
%    The code is executed \emph{only if} the corresponding option
%    is \emph{explicily set} in |\frenchsetup{}|.
%    \begin{macrocode}
\newcommand*{\FBSuppressWarning@setup}[1]%
  {\csname FBSuppressWarning#1\endcsname
   \ifFBSuppressWarning
     \renewcommand{\FBWarning}[1]{}%
   \fi
  }
\newcommand*{\FBStandardLayout@setup}[1]%
  {\ifFB@mainlanguage@FR
     \csname FBStandardLayout#1\endcsname
   \else
     \FBWarning{Option `StandardLayout' skipped:\MessageBreak
                French is *not* babel's last option.\MessageBreak
                Reported}%
   \fi
   \ifFBStandardLayout
     \FBStandardListSpacingtrue
     \FBStandardItemizeEnvtrue
     \FBStandardItemLabelstrue
     \FBStandardEnumerateEnvtrue
     \FBIndentFirstfalse
     \FBFrenchFootnotesfalse
     \FBAutoSpaceFootnotesfalse
   \else
     \FBStandardListSpacingfalse
     \FBStandardItemizeEnvfalse
     \FBStandardItemLabelsfalse
     \FBStandardEnumerateEnvfalse
     \FBIndentFirsttrue
     \FBFrenchFootnotestrue
     \FBAutoSpaceFootnotestrue
   \fi
  }
\newcommand*{\FBNosepItemize@setup}[1]%
  {\csname FBNosepItemize#1\endcsname
  }
\newcommand*{\FBNosepEnumerate@setup}[1]%
  {\csname FBNosepEnumerate#1\endcsname
  }
\newcommand*{\FBStandardLists@setup}[1]%
  {\csname FBStandardLists#1\endcsname
   \ifFBStandardLists
     \FBStandardListSpacingtrue
     \FBStandardItemizeEnvtrue
     \FBStandardEnumerateEnvtrue
     \FBStandardItemLabelstrue
   \else
     \FBStandardListSpacingfalse
     \FBStandardItemizeEnvfalse
     \FBStandardEnumerateEnvfalse
     \FBStandardItemLabelsfalse
   \fi
  }
\newcommand*{\FBThinColonSpace@setup}[1]%
  {\csname FBThinColonSpace#1\endcsname
   \ifFBThinColonSpace
     \renewcommand*{\FBcolonspace}{\FBthinspace}%
   \fi
  }
\newcommand*{\FBSmallCapsFigTabCaptions@setup}[1]%
  {\csname FBSmallCapsFigTabCaptions#1\endcsname
   \ifFBSmallCapsFigTabCaptions
   \else
     \let\FBfigtabshape\relax
   \fi
  }
\newcommand*{\FBCustomiseFigTabCaptions@setup}[1]%
  {\csname FBCustomiseFigTabCaptions#1\endcsname
   \ifFBCustomiseFigTabCaptions
     \FBWarning{Option CustomiseFigTabCaptions is *OBSOLETE*\MessageBreak
              The "caption" package is your friend,\MessageBreak
              see "frenchb.pdf" for more hints.\MessageBreak
              Trying to use endash though…\MessageBreak Reported}%
     \IfClassLoadedTF{memoir}%
       {\captiondelim{\space\textendash\space}}%
       {\ifFB@koma
          \renewcommand{\captionformat}{\space\textendash\space}%
        \else
          \IfClassLoadedTF{beamer}%
            {\setbeamertemplate{caption label separator}[endash]}%
            {\RequirePackage[labelsep=endash]{caption}}%
        \fi
       }%
   \fi
  }
\newcommand*{\FBINGuillSpace@setup}[1]%
  {\csname FBINGuillSpace#1\endcsname
   \ifFBINGuillSpace
     \FBsetspaces{guill}{1}{1}{1}%
   \fi
  }
\newcommand*{\FBEveryParGuill@setup}[1]%
  {\expandafter\let\expandafter
      \FBeveryparguill\csname FBguill#1\endcsname
   \ifx\FBeveryparguill\FBguillopen
   \else\ifx\FBeveryparguill\FBguillclose
        \else\ifx\FBeveryparguill\FBguillnone
             \else
               \let\FBeveryparguill\FBguillopen
               \FBWarning{Wrong value for `EveryParGuill':
                          try `open',\MessageBreak
                          `close' or `none'. Reported}%
              \fi
        \fi
   \fi
  }
\newcommand*{\FBEveryLineGuill@setup}[1]%
    {\expandafter\let\expandafter
        \FBeverylineguill\csname FBguill#1\endcsname
     \ifx\FBeverylineguill\FBguillopen
     \else\ifx\FBeverylineguill\FBguillclose
          \else\ifx\FBeverylineguill\FBguillnone
               \else
                 \let\FBeverylineguill\FBguillnone
                 \FBWarning{Wrong value for `EveryLineGuill':
                            try `open',\MessageBreak
                            `close' or `none'. Reported}%
               \fi
          \fi
     \fi
  }
%    \end{macrocode}
%
%    This option has been kept for backward compatibility but is
%    no longer necessary as the |\FB@addGUILspace| attribute for LuaTeX
%    is set to one (true) by default.  A warning is issued.
%    \begin{macrocode}
\newcommand*{\FBog@setup}[1]{%
  \FBWarning{Options og=«, fg=» are not needed with LuaTeX.%
    \MessageBreak Automatic spacing of « » and ‹ › is active.%
    \MessageBreak Use \protect\NoAutoSpacing\space (inside a group) to%
    \MessageBreak cancel spacing locally.\MessageBreak Reported}
}
\newcommand*{\FBfg@setup}[1]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FBprocess@options}
%    |\FBprocess@options| will be executed just before
%    |\begin{document}|: it first checks about packages loaded in the
%    preamble (possibly after \babel) which customise lists: currently
%    \pkg{enumitem}, \pkg{paralist} and \pkg{enumerate};
%    then it processes the options as set by \fbsetup{} or forced for
%    compatibility with packages loaded in the preamble.
%
%    When French is the main language, |\extrasfrench| and
%    |\captionsfrench| are executed by \babel{} at |\begin{document}|,
%    i.e.\ after |\FBprocess@options|.
%
%    \begin{macrocode}
\newcommand*{\FBprocess@options}{%
%    \end{macrocode}
%    Only for legacy lists: update flags (and inform) if a package
%    customising lists has been loaded, currently: \pkg{enumitem},
%    \pkg{paralist}, \pkg{enumerate}.
%    \begin{macrocode}
  \ifFBnewlists
  \else
    \IfPackageLoadedTF{enumitem}{%
      \ifFBStandardItemizeEnv
      \else
        \FBStandardItemizeEnvtrue
        \PackageInfo{french.ldf}%
          {Setting StandardItemizeEnv=true for\MessageBreak
           compatibility with enumitem package,\MessageBreak
           reported}%
       \fi
       \ifFBStandardEnumerateEnv
       \else
         \FBStandardEnumerateEnvtrue
         \PackageInfo{french.ldf}%
           {Setting StandardEnumerateEnv=true for\MessageBreak
            compatibility with enumitem package,\MessageBreak
            reported}%
       \fi}{}%
    \IfPackageLoadedTF{paralist}{%
      \ifFBStandardItemizeEnv
      \else
        \FBStandardItemizeEnvtrue
        \PackageInfo{french.ldf}%
          {Setting StandardItemizeEnv=true for\MessageBreak
           compatibility with paralist package,\MessageBreak
           reported}%
      \fi
      \ifFBStandardEnumerateEnv
      \else
        \FBStandardEnumerateEnvtrue
        \PackageInfo{french.ldf}%
          {Setting StandardEnumerateEnv=true for\MessageBreak
           compatibility with paralist package,\MessageBreak
           reported}%
      \fi}{}%
    \IfPackageLoadedTF{enumerate}{%
      \ifFBStandardEnumerateEnv
      \else
        \FBStandardEnumerateEnvtrue
        \PackageInfo{french.ldf}%
          {Setting StandardEnumerateEnv=true for\MessageBreak
           compatibility with enumerate package,\MessageBreak
           reported}%
      \fi}{}%
  \fi
%    \end{macrocode}
%
% \changes{v4.0b}{2025-07-02}{New code to customise footnotes when
%    the new templates are available.}
%
%    Options \fbo{FrenchFootnotes} and Option \fbo{AutoSpaceFootnotes}
%    are handled now when new footnotes templates are available.
%
%    \begin{macrocode}
  \ifFBnewfootnotes
    \FB@newFootnotesSetup
  \fi
%    \end{macrocode}
%    Option \fbo{SmallCapsFigTabCaptions}:
%    |\figurename| and |\tablename| are printed in small caps (in French
%    \emph{only}), unless either \fbo{SmallCapsFigTabCaptions} is set to
%    \fbo{false} or a class or package loaded defines |\FBfigtabshape|
%    as |\relax|.
%    As |\figurename| and |\tablename| should not include font commmands,
%    we customise |\fnum@figure| and |\fnum@table| when available (not in
%    beamer.cls f.i.).
%    \begin{macrocode}
  \ifx\FBfigtabshape\relax
  \else
    \ifdefined\fnum@figure
      \let\fnum@figureORI\fnum@figure
      \renewcommand{\fnum@figure}{{\ifFBfrench\FBfigtabshape\fi
                                   \fnum@figureORI}}%
    \fi
    \ifdefined\fnum@table
      \let\fnum@tableORI\fnum@table
      \renewcommand{\fnum@table}{{\ifFBfrench\FBfigtabshape\fi
                                  \fnum@tableORI}}%
    \fi
  \fi
%    \end{macrocode}
%    \fbo{AutoSpacePunctuation}, when \opt{true}, adds a non-breaking
%    space (in French only) before the four characters (:;!?) if and
%    only if spacing is required by French typographic rules.
%    When \fbo{false}, these characters  are left unchanged.
%    \begin{macrocode}
  \ifFBAutoSpacePunctuation
    \autospace@beforeFDP
  \else
    \noautospace@beforeFDP
    \FBWarning{AutoSpacePunctuation should *not* be set to false%
    \MessageBreak in LuaTeX, unless you know what you are doing.%
    \MessageBreak Reported}
  \fi
%    \end{macrocode}
%
% \changes{v4.1a}{2026-03-30}{Redefinition of \cs{ttfamily} replaced
%    by a NFSS hook.}
%
%    When \fbo{OriginalTypewriter} is set to \fbo{false} (the default),
%    a \emph{hook} is added to |\ttfamily|, to prevent addition of
%    automatic spaces before the four active characters in computer code.
%    |\rmfamily| and |\sffamily| need to be redefined also, as
%    |\ttfamily| is not always used inside a group.
%    \begin{macrocode}
  \ifFBOriginalTypewriter
  \else
    \AddToHook{ttfamily}{\FB@spacing=\z@}%
    \AddToHook{rmfamily}{\FB@spacing=\@ne}%
    \AddToHook{sffamily}{\FB@spacing=\@ne}%
  \fi
%    \end{macrocode}
%
%    When package \pkg{numprint} is loaded with option
%    \opt{autolanguage}, \pkg{numprint}’s command |\npstylefrench| has
%    to be redefined differently according to the value of
%    flag\linebreak \fbo{ThinSpaceInFrenchNumbers}.
%    As |\npstylefrench| was undefined in old versions of
%    \pkg{numprint}, we provide this command.
%    \begin{macrocode}
  \IfPackageLoadedTF{numprint}%
    {\ifnprt@autolanguage
       \providecommand*{\npstylefrench}{}%
       \ifFBThinSpaceInFrenchNumbers
         \renewcommand*{\FBthousandsep}{\FBthinspace}%
       \fi
       \g@addto@macro\npstylefrench{\npthousandsep{\FBthousandsep}}%
     \fi
    }{}%
%    \end{macrocode}
%    \fbo{FrenchSuperscripts}: if \fbo{true}, try to take advantage of
%    the \pkg{realscripts} package if it has been loaded.
%    In case the current font has no real superscripts (lmodern…),
%    |\fup| is preferred to |\fakesuperscript|.
%    The star-form |\up*=\fup| is provided for fonts that lack some
%    superior letters: f.i.\ Adobe Jenson Pro has no superiors for
%    ``c,f,g,j,k,p,q’’.
%    \begin{macrocode}
  \ifFBFrenchSuperscripts
    \IfPackageLoadedTF{realscripts}%
      {\RenewDocumentCommand\fakesuperscript{m}{\fup{##1}}%
       \NewDocumentCommand\FB@up{m}{%
            \realsuperscript{\FB@lc{##1}}}%
        \DeclareRobustCommand*{\up}{%
            \texorpdfstring{\@ifstar{\fup}{\FB@up}}%
                           {}%
            }%
       }
       {\DeclareRobustCommand*{\up}{%
           \texorpdfstring{\@ifstar{\fup}{\fup}}%
                          {}%
           }%
       }
  \else
%    \end{macrocode}
%    If \fbo{false}, use the standard command |\textsuperscript|.
%    The star-form |\up*| remains defined as |\fup|.
%    When \pkg{realscripts} has been loaded, |\textsuperscript| is
%    |\realsuperscript|, uppercased argument would be printed as is
%    (most fonts do not have superscripts for uppercased letters).
%    \begin{macrocode}
    \NewDocumentCommand\FB@up{m}{%
        \textsuperscript{\FB@lc{##1}}}%
    \DeclareRobustCommand*{\up}{%
        \texorpdfstring{\@ifstar{\fup}{\FB@up}}%
                       {}%
        }%
  \fi
%    \end{macrocode}
%    \fbo{LowercaseSuperscripts}: if \fbo{false} |\FB@lc| is redefined
%    to do nothing.
%    \begin{macrocode}
  \ifFBLowercaseSuperscripts
  \else
    \renewcommand*{\FB@lc}[1]{##1}%
  \fi
%    \end{macrocode}
%    Option \fbo{UnicodeNoBreakSpaces} is meant for HTML translators:
%    when true, all non-breaking spaces added by \frenchb{} are coded in
%    the PDF file as Unicode characters, namely U+A0 or U+202F, instead
%    of penalties and glues.
%    \begin{macrocode}
  \ifFBUnicodeNoBreakSpaces
    \FB@ucsNBSP=\@ne
    \renewcommand*{\FBmedkern}{\char"202F\relax}%
    \renewcommand*{\FBthickkern}{\char"A0\relax}%
    \ifFBThinSpaceInFrenchNumbers
      \renewcommand*{\FBthousandsep}{\char"202F\relax}%
    \else
      \renewcommand*{\FBthousandsep}{\char"A0\relax}%
    \fi
 \fi
%    \end{macrocode}
%    \fbo{TocPartNameFull}: for \cls{memoir} and koma-script classes only.
%    |\KOMAoptions| cannot be changed `AtBeginDocument’, executing
%    |\FBprocess@options| just before is fine.
%    \begin{macrocode}
  \ifFB@koma
     \ifFBTocPartNameFull
       \KOMAoptions{toc=flat, numbers=nodotatend}%
       \renewcommand*{\addparttocentry}[2]{%
          \addtocentrydefault{part}{\FBtocpartname{##1}}{##2}}%
     \fi
  \fi
  \IfClassLoadedTF{memoir}%
     {\ifFBTocPartNameFull
        \renewcommand{\partnumberline}[1]{\FBtocpartname{##1}}%
      \fi
     }{}%
%    \end{macrocode}
%    \fbo{ShowOptions}: if \fbo{true}, print the list of all options
%    to the \file{.log} file.
%    \begin{macrocode}
  \ifFBShowOptions
    \GenericWarning{* }{%
     *** List of possible options for babel-french ***\MessageBreak
     [Default values between brackets when french is loaded *LAST*]%
     \MessageBreak
     ShowOptions [false]\MessageBreak
     StandardLayout [false]\MessageBreak
     PartNameFull [true]\MessageBreak
     TocPartNameFull [true]\MessageBreak
     IndentFirst [true]\MessageBreak
     ListItemsAsPar [false]\MessageBreak
     StandardListSpacing [false]\MessageBreak
     NosepItemize [true]\MessageBreak
     NosepEnumerate [false]\MessageBreak
     StandardItemLabels [false]\MessageBreak
     ItemLabels=\textemdash, \textbullet,
        \protect\ding{43},... [\textendash]\MessageBreak
     ItemLabeli=\textemdash, \textbullet,
        \protect\ding{43},... [\textendash]\MessageBreak
     ItemLabelii=\textemdash, \textbullet,
        \protect\ding{43},... [\textendash]\MessageBreak
     ItemLabeliii=\textemdash, \textbullet,
        \protect\ding{43},... [\textendash]\MessageBreak
     ItemLabeliv=\textemdash, \textbullet,
        \protect\ding{43},... [\textendash]\MessageBreak
     StandardLists [false]\MessageBreak
     FrenchFootnotes [true]\MessageBreak
     AutoSpaceFootnotes [true]\MessageBreak
     AutoSpacePunctuation [true]\MessageBreak
     ThinColonSpace [false]\MessageBreak
     ThinSpaceInFrenchNumbers [false]\MessageBreak
     UnicodeNoBreakSpaces [false]\MessageBreak
     OriginalTypewriter [false]\MessageBreak
     INGuillSpace [false]\MessageBreak
     EveryParGuill=open, close, none [open]\MessageBreak
     EveryLineGuill=open, close, none
                   [open in LuaTeX, none otherwise]\MessageBreak
     InnerGuillSingle [false]\MessageBreak
     SmallCapsFigTabCaptions [true]\MessageBreak
     FrenchSuperscripts [true]\MessageBreak
     LowercaseSuperscripts [true]\MessageBreak
     SuppressWarning [false]\MessageBreak
     \MessageBreak
     *********************************************%
     \MessageBreak\protect\frenchsetup{ShowOptions}}
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \changes{v4.0d}{2025-07-25}{\cs{FBprocess@options} must be processed
%    only once, reported by Herbert Voß for dtk.cls.}
%
% \changes{v4.0e}{2025-08-15}{\cs{AddToHook} for env/document/ replaced
%    by \cs{AddToHookNext} (all instances).}
%
%    Just before |\begin{document}|, let’s now process the remaining
%    options, either not explicitly set by \fbsetup{} or possibly
%    modified by packages loaded after \frenchb.
%    We also have to provide an |\xspace| command in case the
%    \pkg{xspace} package is not loaded.
%    In some cases (package \pkg{standalone}, \cls{dtk},…) several
%    |\documentclass{}| commands are allowed, so use |\AddToHookNext|
%    instead of |\AddToHook| (all instances) as our stuff should only
%    added to the first occurence of |\documentclass{}| anyway.
%    \begin{macrocode}
\AddToHookNext{env/document/before}{%
   \providecommand*{\xspace}{\relax}%
   \FBprocess@options
}
%    \end{macrocode}
%
%  \subsection{French lists}
%  \label{ssec-lists}
%
%  \subsubsection{Code shared by new and legacy lists}
%
% \begin{macro}{\listindentFB}
% \begin{macro}{\descindentFB}
% \begin{macro}{\labelwidthFB}
% \begin{macro}{\labelfullwidthFB}
%    {\sloppy Let’s define three dimens |\listindentFB|, |\descindentFB|,
%    and |\labelwidthFB| to customise lists’ horizontal indentations.
%    They are given silly negative values here in order to eventually
%    enable their customisation in the preamble.  They will get
%    reasonnable defaults later when entering French (see below
%    |\setlistindentFB| and |\setlabelitemsFB|) unless they have been
%    customised before.\par}
%    \begin{macrocode}
\newdimen\listindentFB
\setlength{\listindentFB}{-1pt}
\newdimen\descindentFB
\setlength{\descindentFB}{-1pt}
\newdimen\labelwidthFB
\setlength{\labelwidthFB}{-1pt}
\newdimen\labelfullwidthFB
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    The next function will be included in |\setup@FBnewlists| or
%    |\setup@FBlegacylists| which are exectuted in |\extrasfrench{}|
%    `AtBeginDocument’.
%    \begin{macrocode}
\def\setlistindentFB{%
  \ifdim\listindentFB<\z@
    \ifdim\parindent=\z@
      \setlength{\listindentFB}{1.5em}%
    \else
      \setlength{\listindentFB}{\parindent}%
    \fi
  \fi
  \ifdim\descindentFB<\z@
    \setlength{\descindentFB}{\listindentFB}%
  \fi
}
%    \end{macrocode}
%
%    Let’s consider French itemize-lists.  They differ from those
%    provided by the standard LaTeX classes:
%    \begin{itemize}
%      \item The `\textbullet’ is never used in French itemize-lists,
%          an emdash `---’ or an endash  `--’ is preferred for all
%          levels.  The item label to be used in French, stored in
%          |\FrenchLabelItem}|, defaults to `---’ and can be changed
%          using \fbsetup{} (see section~\ref{ssec-keyval}).
%      \item Vertical spacing between items, before and after
%         the list, should be \emph{null} with \emph{no glue} added;
%      \item The labels of itemize-lists are vertically
%         aligned as shown p.~\pageref{ListAsPar}.
%    \end{itemize}
%
% \begin{macro}{\FrenchLabelItem}
% \begin{macro}{\Frlabelitemi}
% \begin{macro}{\Frlabelitemii}
% \begin{macro}{\Frlabelitemiii}
% \begin{macro}{\Frlabelitemiv}
%    Default labels for French itemize-lists ---same label for all
%    levels---, (already defined as empty by |\DeclareKey{}|):
%    \begin{macrocode}
\renewcommand*{\FrenchLabelItem}{\textemdash}
\renewcommand*{\Frlabelitemi}{\FrenchLabelItem}
\renewcommand*{\Frlabelitemii}{\FrenchLabelItem}
\renewcommand*{\Frlabelitemiii}{\FrenchLabelItem}
\renewcommand*{\Frlabelitemiv}{\FrenchLabelItem}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    The next function will be included in |\setup@FBnewlists| or
%    |\setup@FBlegacylists| which are exectuted in |\extrasfrench{}|
%    `AtBeginDocument’.
%    \begin{macrocode}
\def\setlabelitemsFB{%
  \let\labelitemi\Frlabelitemi
  \let\labelitemii\Frlabelitemii
  \let\labelitemiii\Frlabelitemiii
  \let\labelitemiv\Frlabelitemiv
}
%    \end{macrocode}
%
%  \subsubsection{Code for legacy lists only}
%
% \begin{macro}{\listFB}
% \changes{v3.5q}{2023-02-15}{Bug correction: \cs{parsep} should be
%    related to \cs{parskip} and \cs{listparindent} to \cs{parindent}.}
% \begin{macro}{\listORI}
% \begin{macro}{\FB@listVsettings}
%    Vertical spacing in lists should be shorter in French texts than
%    the defaults provided by LaTeX.
%    Note that the easy way, just changing values of vertical spacing
%    parameters when entering French and restoring them to their
%    defaults on exit would not work; so we define the command
%    |\FB@listVsettings| to hold the settings to be used by
%    the French variant |\listFB| of |\list|.  Note that switching
%    to |\listFB| reduces vertical spacing in \emph{all} environments
%    built on |\list|: |itemize|, |enumerate|, |description|, but also
%    |abstract|, |quotation|, |quote| and |verse|…
%
%    The amount of vertical space before and after a list is given by
%    |\topsep| + |\parskip| (+ |\partopsep| if the list starts a new
%    paragraph).  IMHO, |\parskip| should be added \emph{only} when
%    the list starts a new paragraph, so I subtract |\parskip| from
%    |\topsep| and add it back to |\partopsep|; this will normally
%    make no difference because |\parskip|’s default value is 0pt, but
%    will be noticeable when |\parskip| is \emph{not} null.
%
%    \begin{macrocode}
\ifFBnewlists
\else
  \let\listORI\list
  \let\endlistORI\endlist
  \newdimen\FB@pardim
  \def\FB@listVsettings{%
      \setlength{\topsep}{0.8ex plus 0.4ex minus 0.4ex}%
      \setlength{\partopsep}{0.4ex plus 0.2ex minus 0.2ex}%
      \setlength{\itemsep}{0.4ex plus 0.2ex minus 0.2ex}%
      \setlength{\parsep}{0.4ex plus 0.2ex minus 0.2ex}%
%    \end{macrocode}
%    |\parskip| is of type `skip’, its mean value only (\emph{not
%    the glue}) should be subtracted from |\topsep| and added to
%    |\partopsep|, so convert |\parskip| to a `dimen’ using
%    |\FB@pardim|.
%    \begin{macrocode}
      \FB@pardim=\parskip
%    \end{macrocode}
%    If |\parskip| is not null, |\parsep| is set to |\parskip|,
%    so paragraphs inside items will be preceeded by the same vertical
%    space as paragraphs located outside lists; the vertical skip before
%    items (|\itemsep| + |\parsep|) doesn’t need to be enlarged.
%    \begin{macrocode}
      \ifdim\FB@pardim>\z@
        \addtolength{\topsep}{-\FB@pardim}%
        \addtolength{\partopsep}{\FB@pardim}%
        \setlength{\parsep}{\FB@pardim}%
        \addtolength{\itemsep}{-\FB@pardim}%
      \fi
  }
  \def\listFB#1#2{\listORI{#1}{\FB@listVsettings #2}}
  \let\endlistFB\endlistORI
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v3.5a}{2018-07-04}{New optional layout for lists:
%    lists’ items can be typeset as paragraphs with indented labels
%    while the default leaves the labels hanging into the left margin.}
%
%\begin{macro}{\FB@listHsettings}
%    |\FB@listHsettings| holds the new horizontal settings chosen for
%    French lists \env{itemize}, \env{enumerate} and \env{description}
%    (two possible layouts).
%    \begin{macrocode}
  \def\FB@listHsettings{%
    \ifdim\labelwidthFB<\z@
      \settowidth{\labelwidthFB}{\FrenchLabelItem}%
    \fi
    \labelfullwidthFB=\labelwidthFB
    \advance\labelfullwidthFB by \labelsep
    \ifFBListItemsAsPar
%    \end{macrocode}
%    Optional layout: lists’ items are typeset as paragraphs with
%    indented labels.
%    \begin{macrocode}
      \leftmargini=\z@
      \itemindent=\labelfullwidthFB
      \advance\itemindent by \listindentFB
      \bbl@for\FB@dp {2, 3, 4, 5, 6}%
        {\csname leftmargin\romannumeral\FB@dp\endcsname =
           \listindentFB}%
    \else
%    \end{macrocode}
%    Default layout: labels hanging into the list left margin.
%    \begin{macrocode}
      \bbl@for\FB@dp {1, 2, 3, 4, 5, 6}%
        {\csname leftmargin\romannumeral\FB@dp\endcsname =
           \labelfullwidthFB}%
      \advance\leftmargini by \listindentFB
      \itemindent=\z@
%    \end{macrocode}
%    Same `parindent’ for paragraphs in lists’ items (was null
%    as in standard lists).
%    \begin{macrocode}
    \fi
    \listparindent=\parindent
    \leftmargin=\csname leftmargin%
       \ifnum\@listdepth=\@ne i\else ii\fi\endcsname
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\itemizeFB}
% \begin{macro}{\FB@itemizeVsettings}
%    New environment for French itemize-lists.\\ |\FB@itemizeVsettings|
%    suppresses all vertical spaces including glue
%    unless option \fbo{StandardListSpacing} is set.
%    \begin{macrocode}
  \def\FB@itemizeVsettings{%
    \ifFBStandardListSpacing
    \else
      \FB@pardim=\parskip
      \ifdim\FB@pardim>\z@
        \setlength{\topsep}{-\FB@pardim}%
        \setlength{\partopsep}{\FB@pardim}%
        \setlength{\parsep}{\FB@pardim}%
        \setlength{\itemsep}{-\FB@pardim}%
      \else
        \setlength{\topsep}{\z@}%
        \setlength{\partopsep}{\z@}%
        \setlength{\parsep}{\z@}%
        \setlength{\itemsep}{\z@}%
      \fi
    \fi
}
%    \end{macrocode}
%    The definition of |\itemizeFB| follows the one of |\itemize|
%    in standard LaTeX classes (see \file{ltlists.dtx}), vertical
%    spaces are customised by |\FB@itemizeVsettings|.
%
%    \begin{macrocode}
  \def\itemizeFB{%
    \ifnum \@itemdepth >\thr@@\@toodeep\else
      \advance\@itemdepth by \@ne
      \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
      \expandafter
      \listORI
      \csname\@itemitem\endcsname
      {\FB@itemizeVsettings
       \settowidth{\labelwidth}{\csname\@itemitem\endcsname}%
       \FB@listHsettings
      }%
    \fi
  }
  \let\enditemizeFB\endlistORI
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\enumerateFB}
%    The definition of |\enumerateFB|, new to version~2.6a, follows
%    the one of |\enumerate| in standard LaTeX classes (see
%    \file{ltlists.dtx}), vertical spaces are customised (or not)
%    via |\list| (=|\listFB| or |\listORI|) and horizontal spaces
%    (leftmargins) are borrowed from |itemize| lists via
%    |\FB@listHsettings|.
%
%    \begin{macrocode}
  \def\enumerateFB{%
    \ifnum \@enumdepth >\thr@@\@toodeep\else
      \advance\@enumdepth by \@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\FB@listHsettings
         \usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
    \fi
  }
  \let\endenumerateFB\endlistORI
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\descriptionFB}
%    Same tuning for the \env{description} environment (see
%    \file{classes.dtx} for the original definition).
%    Customisable dimen |\descindentFB|, which defaults to
%    |\listindentFB|, is added to |\itemindent| (first level only).
%    When |\descindentFB=0pt| (1rst level labels start at the left
%    margin), |\leftmargini| is reduced to |\listindentFB| instead
%    of |\listindentFB| + |\labelfullwidthFB|.
%
%    When option \fbo{ListItemsAsPar} is turned to \fbo{true}, the
%    \env{description} items are also displayed as paragraphs;
%    |\descindentFB=0pt| can be used to push labels to the left margin.
%    \begin{macrocode}
  \def\descriptionFB{%
    \list{}{\FB@listHsettings
            \labelwidth=\z@
            \ifFBListItemsAsPar
              \itemindent=\descindentFB
            \else
              \itemindent=-\leftmargin
              \ifnum\@listdepth=\@ne
                \ifdim\descindentFB=\z@
                  \ifdim\listindentFB>\z@
                    \leftmargini=\listindentFB
                    \leftmargin=\leftmargini
                    \itemindent=-\leftmargin
                  \fi
                \else
                  \advance\itemindent by \descindentFB
                \fi
              \fi
            \fi
            \let\makelabel\descriptionlabel
           }%
  }
  \let\enddescriptionFB\endlistORI
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setup@FBlegacylists}
%    This command gathers the customisation of French lists when the
%    new templates are not available: the legacy lists are redefined.
%    \begin{macrocode}
\def\setup@FBlegacylists{%
    \setlistindentFB
    \ifFBStandardListSpacing
    \else \let\list\listFB \fi
    \ifFBStandardItemizeEnv
    \else \let\itemize\itemizeFB \fi
    \ifFBStandardItemLabels
    \else \setlabelitemsFB \fi
    \ifFBStandardEnumerateEnv
    \else \let\enumerate\enumerateFB \let\description\descriptionFB \fi
  }
\def\warning@FBlegacylists{%
  \FBWarning{You are relying on the legacy list code.\MessageBreak
         There is nothing wrong with this, just be aware\MessageBreak
         that new lists templates are available and will\MessageBreak
         become the default sooner or later.\MessageBreak
         Adding \protect\DocumentMetadata{ ... } before the\MessageBreak
	     \protect\documentclass{} command, enables the new\MessageBreak
         lists templates.  Give them a try!\MessageBreak Reported}%
}
%    \end{macrocode}
% \end{macro}
%
%  \subsubsection{Code for new lists only}
%
% \begin{macro}{\setup@FBnewlists}
% \changes{v4.1a}{2026-01-30}{ offers now customization for the new
%   lists templates.}
%
%    Customization possibilities for the new lists templates:
%    \begin{macrocode}
\ifFBnewlists
   \newdimen\itemindentFB
   \newdimen\leftmarginiFB
   \newdimen\leftmarginiiFB
   \def\setup@FBnewlists{%
     \setlistindentFB
%    \end{macrocode}
%    Compute |\leftmarginiFB|, |\leftmarginiiFB| and |\itemidentFB| for
%    both possible layouts (default and ListItemsAsPar).
%    \begin{macrocode}
     \ifdim\labelwidthFB<\z@
       \settowidth{\labelwidthFB}{\FrenchLabelItem}%
     \fi
     \labelfullwidthFB=\labelwidthFB
     \advance\labelfullwidthFB by \labelsep
     \ifFBListItemsAsPar
       \leftmarginiFB=\z@
       \leftmarginiiFB=\listindentFB
       \itemindentFB=\labelfullwidthFB
       \advance\itemindentFB by \listindentFB
     \else
       \leftmarginiFB=\listindentFB
       \advance\leftmarginiFB by \labelfullwidthFB
       \leftmarginiiFB=\labelfullwidthFB
       \itemindentFB=\z@
     \fi
     \listparindent=\parindent
%    \end{macrocode}
%    Let’s define lists’ variants with tight or nosep vertical spacing
%    (6 levels).
%    \begin{macrocode}
     \DeclareInstance{block}{tight-list-1}{std}{%
          begin-vspace = 0.8ex plus 0.4ex minus 0.4ex ,
          begin-extra-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          para-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          item-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          left-margin:v = leftmarginiFB ,
     }%
     \DeclareInstance{block}{tight-list-2}{std}{%
          begin-vspace = 0.8ex plus 0.4ex minus 0.4ex ,
          begin-extra-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          para-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          item-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          left-margin:v = leftmarginiiFB ,
     }%
     \DeclareInstanceCopy{block}{tight-list-3}{tight-list-2}%
     \DeclareInstanceCopy{block}{tight-list-4}{tight-list-2}%
     \DeclareInstanceCopy{block}{tight-list-5}{tight-list-2}%
     \DeclareInstanceCopy{block}{tight-list-6}{tight-list-2}%
     %
     \DeclareInstance{block}{nosep-list-1}{std}{%
          begin-vspace = 0pt ,
          begin-extra-vspace = 0pt ,
          para-vspace = 0pt ,
          item-vspace = 0pt ,
          left-margin:v = leftmarginiFB ,
     }%
     \DeclareInstance{block}{nosep-list-2}{std}{%
          begin-vspace = 0pt ,
          begin-extra-vspace = 0pt ,
          para-vspace = 0pt ,
          item-vspace = 0pt ,
          left-margin:v = leftmarginiiFB ,
     }%
     \DeclareInstanceCopy{block}{nosep-list-3}{nosep-list-2}%
     \DeclareInstanceCopy{block}{nosep-list-4}{nosep-list-2}%
     \DeclareInstanceCopy{block}{nosep-list-5}{nosep-list-2}%
     \DeclareInstanceCopy{block}{nosep-list-6}{nosep-list-2}%
%    \end{macrocode}
%    Itemize lists vertical spacing (std, tight or nosep):
%    \begin{macrocode}
     \ifFBStandardItemizeEnv
     \else
       \ifFBStandardListSpacing
       \else
         \ifFBNosepItemize
           \EditInstance{blockenv}{itemize}{%
              block-instance = nosep-list ,
           }%
         \else
           \EditInstance{blockenv}{itemize}{%
              block-instance = tight-list ,
           }%
         \fi
       \fi
       \EditInstance{list}{itemize-1}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{itemize-2}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{itemize-3}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{itemize-4}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
     \fi
%    \end{macrocode}
%    Labels for Itemize lists (4 levels):
%    \begin{macrocode}
     \ifFBStandardItemLabels
     \else
       \setlabelitemsFB
     \fi
%    \end{macrocode}
%    Enumerate and description  lists vertical spacing (std, tight or
%    nosep):
%    \begin{macrocode}
     \ifFBStandardEnumerateEnv
     \else
       \ifFBStandardListSpacing
       \else
         \ifFBNosepEnumerate
           \EditInstance{blockenv}{enumerate}{%
              block-instance = nosep-list ,
           }%
           \EditInstance{blockenv}{description}{%
              block-instance = nosep-list ,
              inner-instance = description ,
           }%
         \else
           \EditInstance{blockenv}{enumerate}{%
              block-instance = tight-list ,
           }%
           \EditInstance{blockenv}{description}{%
              block-instance = tight-list ,
              inner-instance = description ,
           }%
         \fi
       \fi
%    \end{macrocode}
%    Enumerate and description  lists indentation (4 levels for enumerate,
%    6 levels for description):
%    \begin{macrocode}
       \EditInstance{list}{enumerate-1}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{enumerate-2}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{enumerate-3}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       \EditInstance{list}{enumerate-4}{%
          item-indent:v = itemindentFB ,
          label-width:v = labelfullwidthFB ,
       }%
       %
      \ifFBListItemsAsPar
        \leftmarginiFB=\z@
        \itemindentFB=\descindentFB
      \else
        \leftmarginiFB=\descindentFB
        \advance\leftmarginiFB by \labelfullwidthFB
        \itemindentFB=-\labelwidthFB
      \fi
      \EditInstance{list}{description-1}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
      \EditInstance{list}{description-2}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
      \EditInstance{list}{description-3}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
      \EditInstance{list}{description-4}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
      \EditInstance{list}{description-5}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
      \EditInstance{list}{description-6}{%
          item-indent:v = itemindentFB ,
          label-width = 0pt ,
       }%
     \fi
%    \end{macrocode}
%    Quote (and verse) and quotation (and abstract) environments vertical
%    spacing (standard or tight):
%    \begin{macrocode}
     \ifFBStandardListSpacing
     \else
       \EditInstance{block}{quote-1}{%
          begin-vspace = 0.8ex plus 0.4ex minus 0.4ex ,
          begin-extra-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          para-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
       }%
       \DeclareInstanceCopy{block}{quote-2}{quote-1}%
       \DeclareInstanceCopy{block}{quote-3}{quote-1}%
       \DeclareInstanceCopy{block}{quote-4}{quote-1}%
       \DeclareInstanceCopy{block}{quote-5}{quote-1}%
       \DeclareInstanceCopy{block}{quote-6}{quote-1}%
       \EditInstance{block}{quotation-1}{%
          begin-vspace = 0.8ex plus 0.4ex minus 0.4ex ,
          begin-extra-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
          para-vspace = 0.4ex plus 0.2ex minus 0.2ex ,
       }%
       \DeclareInstanceCopy{block}{quotation-2}{quotation-1}%
       \DeclareInstanceCopy{block}{quotation-3}{quotation-1}%
       \DeclareInstanceCopy{block}{quotation-4}{quotation-1}%
       \DeclareInstanceCopy{block}{quotation-5}{quotation-1}%
       \DeclareInstanceCopy{block}{quotation-6}{quotation-1}%
     \fi
    }
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bbl@frenchlistlayout}
%    Nothing has to be done at language’s switches regarding lists,
%    except at the first switch in case French is the main language,
%    then lists are set up once for all.
%    There is nothing to do for lists in |\noextrasfrench|.
%
%    \begin{macrocode}
\def\bbl@frenchlistlayout{%
  \ifFB@mainlanguage@FR
    \ifFBnewlists
      \setup@FBnewlists
      \let\setup@FBnewlists\relax
    \else
%    \end{macrocode}
%    Warnings: no list customisation with new templates if
%    LaTeX Format < 2026-06-01.
%    \begin{macrocode}
      \IfDocumentMetadataTF
        {\warning@FBLaTeXFormat
         \global\let\warning@FBLaTeXFormat\relax
        }%
        {\warning@FBlegacylists
         \global\let\warning@FBlegacylists\relax
         \setup@FBlegacylists
         \let\setup@FBlegacylists\relax
        }%
    \fi
  \fi}
\addto\extrasfrench{\bbl@frenchlistlayout}
%    \end{macrocode}
% \end{macro}
%
%  \subsection{French indentation of sections}
%  \label{ssec-indent}
%
% \begin{macro}{\bbl@frenchindent}
%    In French the first paragraph of each section should be indented,
%    this is another difference with US-English.  This is controlled
%    by the flag |\if@afterindent|.
%
%    Indentation changes at language switches only if
%    |IndentFirst=true| and French isn’t the main language.
%
%    \begin{macrocode}
\def\bbl@frenchindent{%
  \ifFBIndentFirst
    \ifFB@mainlanguage@FR\else\babel@save\@afterindentfalse\fi
    \let\@afterindentfalse\@afterindenttrue
    \@afterindenttrue
  \fi}
\addto\extrasfrench{\bbl@frenchindent}
%    \end{macrocode}
% \end{macro}
%
%  \subsection{Formatting footnotes}
%  \label{ssec-footnotes}
%
%    The layout of footnotes is controlled by two flags
%    |\ifFBAutoSpaceFootnotes| and |\ifFBFrenchFootnotes| which are
%    set by options of \fbsetup{} (see section~\ref{ssec-keyval}).
%    The layout of footnotes only depends on the main language (French
%    or other). Two cases: new templates or legacy code.
%
%  \subsection{Common settings for both new and old footnote's code}
%
% \begin{macro}{\parindentFFN}
% \begin{macro}{\dotFFN}
% \begin{macro}{\kernFFN}
%    The value of |\parindentFFN| will be redefined at the
%    |\begin{document}|, as the maximum of |\parindent| and 1.8em (like
%    |\footnotemargin|) \emph{unless} it has been set in the preamble.
%    \begin{macrocode}
\newdimen\parindentFFN
\parindentFFN=\maxdimen
%    \end{macrocode}
%    In French, the number preceeding the footnote text is typeset in
%    normal size (not superscript) followed by a dot and a space, both
%    are customisable.
%    \begin{macrocode}
\newcommand*{\dotFFN}{.}
\newcommand*{\kernFFN}{\kern .5em}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FBfnmarkspace}
%    Let’s define a customisable thin space which will be added before
%    footnote’s call.
%    \begin{macrocode}
\newcommand*{\FBfnmarkspace}{\kern .5\fontdimen2\font}
%    \end{macrocode}
% \end{macro}
%
%  \subsubsection{Code for the new footnotes templates}
%
% \begin{macro}{\FB@newFootnotesSetup}
% \changes{v4.1a}{2026-01-30}{Fixes for compatibility with
%    footmisc.sty.}
%
%    |\FB@newFootnotesSetup| will be processed by |\FBprocess@options|
%    just before\\ |\begin{document}|.
%    \begin{macrocode}
\ifFBnewfootnotes
  \providecommand*{\multiplefootnotemarker}{3sp}
  \newcommand*{\FBfnmark}{%
    \ifdim\lastkern=\multiplefootnotemarker
    \else \FBfnmarkspace \fi}
  \newcommand*{\FB@newFootnotesSetup}{%
    \ifdim\parindentFFN<\maxdimen
    \else
       \parindentFFN=\parindent
       \ifdim\parindentFFN<1.8em \parindentFFN=1.8em \fi
    \fi
    \ifFBFrenchFootnotes
      \NewSocketPlug{fntext/mark}{FBfnmark}
        {\hb@xt@ \parindentFFN{\hss\@thefnmark}\dotFFN\kernFFN}
      \AssignSocketPlug{fntext/mark}{FBfnmark}
      \AddToHook{cmd/maketitle/before}[.]
         {\AssignSocketPlug{fntext/mark}{default}}
      \AddToHook{cmd/maketitle/after}[.]
         {\AssignSocketPlug{fntext/mark}{FBfnmark}}
      \AddToHook{env/minipage/begin}[.]
         {\AssignSocketPlug{fntext/mark}{default}}
      \AddToHook{fntext/para}[.]{\parindent=\parindentFFN}
      \AddToHook{fntext/para}[.]{\localleftbox{}}
      \AddToHook{fntext/para}[.]{\let\FBeverypar@quote\relax}
    \fi
    \ifFBAutoSpaceFootnotes
      \AddToHook{fnmark/before}[.]{\FBfnmark}
    \fi
}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Code for legacy footnotes}
%
% \begin{macro}{\@makefntextFB}
%    We define |\@makefntextFB|, a variant of |\@makefntext|
%    which is responsible for the layout of footnotes, to match the
%    specifications of the French `Imprimerie Nationale’:  footnotes
%    will be indented by |\parindentFFN|, numbers (if any) typeset on
%    the baseline (instead of superscripts), right aligned on
%    |\parindentFFN| and followed by a dot and an half quad kern.
%    Whenever symbols are used to number footnotes (as in |\thanks|
%    for instance), we switch back to the standard layout (the French
%    layout of footnotes is meant for footnotes numbered by arabic or
%    roman digits).
%
%    |\@makefntextFB|’s definition depends on the document’s class.
%
%    |\FBfnindent| will be set later on to the width of the box holding
%    the footnote mark, |\dotFFN| and |\kernFFN| (flushed right).
%    It is used by \cls{memoir} and koma-script classes.
%    \begin{macrocode}
\ifFBnewfootnotes
\else
  \newdimen\FBfnindent
%    \end{macrocode}
%
%    Koma-script classes: they provide |\deffootnote|, a handy command
%    to customise the footnotes’ layout (see English manual
%    \file{scrguien.pdf}); it redefines |\@makefntext| and
%    |\@@makefnmark|.  First, save the original definitions.
%    \begin{macrocode}
  \ifFB@koma
    \let\@makefntextORI\@makefntext
    \let\@@makefnmarkORI\@@makefnmark
%    \end{macrocode}
%    |\@makefntextFB| and |\@@makefnmarkFB| are used when option
%    \fbo{FrenchFootnotes} is \fbo{true}.
%    \begin{macrocode}
    \deffootnote[\FBfnindent]{\z@}{\parindentFFN}%
                {\thefootnotemark\dotFFN\kernFFN}
    \let\@makefntextFB\@makefntext
    \let\@@makefnmarkFB\@@makefnmark
%    \end{macrocode}
%    |\@makefntextTH| and |\@@makefnmarkTH| are meant for the
%    |\thanks| command used by |\maketitle| when \fbo{FrenchFootnotes}
%    is \fbo{true}.
%    \begin{macrocode}
    \deffootnote[\parindentFFN]{\z@}{\parindentFFN}%
                {\textsuperscript{\thefootnotemark}}
    \let\@makefntextTH\@makefntext
    \let\@@makefnmarkTH\@@makefnmark
%    \end{macrocode}
%    Restore the original definitions.
%    \begin{macrocode}
    \let\@makefntext\@makefntextORI
    \let\@@makefnmark\@@makefnmarkORI
  \fi
%    \end{macrocode}
%    Definitions for the \cls{memoir} class:
%    \begin{macrocode}
  \IfClassLoadedTF{memoir}
%    \end{macrocode}
%    (see original definition in \file{memman.pdf})
%    \begin{macrocode}
     {\newcommand{\@makefntextFB}[1]{%
        \def\footscript##1{##1\dotFFN\kernFFN}%
        \setlength{\footmarkwidth}{\FBfnindent}%
        \setlength{\footmarksep}{-\footmarkwidth}%
        \setlength{\footparindent}{\parindentFFN}%
        \makefootmark #1}%
     }{}
%    \end{macrocode}
%    Definitions for the \cls{beamer} class:\par
%    the original definition is in
%    \file{beamerbaseframecomponents.sty}, note that for the
%    \cls{beamer} class footnotes are LR-boxes, not paragraphs,
%    so |\parindentFFN| is irrelevant.
%
% \changes{v3.2h}{2016-04-09}{With beamer.cls, add \cs{llap} to
%    \cs{@thefnmark} for notes numbered over 99.}
%
%    \begin{macrocode}
  \IfClassLoadedTF{beamer}
     {\def\@makefntextFB#1{%
        \def\insertfootnotetext{#1}%
        \def\insertfootnotemark{\insertfootnotemarkFB}%
        \usebeamertemplate***{footnote}}%
      \def\insertfootnotemarkFB{%
        \usebeamercolor[fg]{footnote mark}%
        \usebeamerfont*{footnote mark}%
        \llap{\@thefnmark}\dotFFN\kernFFN}%
     }{}
%    \end{macrocode}
%
%    Now the default definition of |\@makefntextFB| for
%    standard LaTeX and AMS classes.
%    The next command prints the footnote mark according to the
%    specifications of the French `Imprimerie Nationale’.
%    Keep in mind that |\@thefnmark| might be empty (i.e.\ in
%    AMS classes’ titles)!
%    \begin{macrocode}
  \providecommand*{\insertfootnotemarkFB}{%
    \parindent=\parindentFFN
    \rule\z@\footnotesep
    \setbox\@tempboxa\hbox{\@thefnmark}%
    \ifdim\wd\@tempboxa>\z@
      \llap{\@thefnmark}\dotFFN\kernFFN
    \fi}
  \providecommand\@makefntextFB[1]{\insertfootnotemarkFB #1}
%    \end{macrocode}
% \end{macro}
%
%    The rest of |\@makefntext|’s customisation will be done at
%    the |\begin{document}|: saving the original definition of
%    |\@makefntext|, then redefining |\@makefntext| according
%    to the value of flag |\ifFBFrenchFootnotes| (true or false).
%
% \begin{macro}{\@footnotemark}
%
% \changes{v3.6a}{2024-05-13}{Allow customisation of the space added
%    in \cs{@footnotemarkFB}.}
%
%    We will save the original definition of |\@footnotemark| at
%    |\begin{document}| in order to include any customisation that
%    packages might have done; we define a variant |\@footnotemarkFB|
%    which just adds a (customisable) thin space before the number or
%    symbol calling a footnote (any space typed in is removed first).
%    The choice between the two definitions (valid for the whole
%    document) is controlled by flag |\ifFBAutoSpaceFootnotes|.
%
%    |\@footnotemark|’s customisation: |\FBfnmarkspace| will be added
%    before footnote’s call by |\@footnotemarkFB|.
%    \begin{macrocode}
  \def\@footnotemarkFB{\leavevmode\unskip\unkern
                       \protect\FBfnmarkspace\@footnotemarkORI}%
%    \end{macrocode}
% \end{macro}
%
% \changes{v3.3c}{2017-07-28}{Reset \cs{localleftbox} locally
%    inside \cs{@makefntext}.  Needed by \cs{frquote} with LuaTeX.}
%
% \changes{v3.5b}{2018-07-17}{Reset \cs{FBeverypar@quote} locally
%    inside \cs{@makefntext}.  Needed by \cs{frquote}.}
%
% \changes{v3.5c}{2018-09-13}{Remove grouping inside \cs{@makefntext},
%    \cs{localleftbox} and \cs{FBeverypar@quote} saved and restored
%    instead.}
%
%    The following command |\FB@legacyFootnoteSetup| will be  processed
%    just before |\begin{document}| by |\FBprocess@options| . It gathers
%    the customisation of footnotes in French.
%
%    The LuaTeX command |\localleftbox| and |\FBeverypar@quote| used
%    by |\frquote{}| have to be reset inside footnotes; done for LaTeX
%    based formats only.
%    \begin{macrocode}
  \newcommand*{\FB@legacyFootnoteSetup}{%
%    \end{macrocode}
%    When the \pkg{footnotebackref} package is loaded, \frenchb{}
%    will not customise |\@footnotetext| in order to keep back
%    referencing working.
%    \begin{macrocode}
    \IfPackageLoadedTF{footnotebackref}%
      {\FBFrenchFootnotesfalse
       \FBWarning
          {footnotebackref package loaded.\MessageBreak
           babel-french will NOT customise footnotes;%
           \MessageBreak reported}}%
      {}%
%    \end{macrocode}
%    The \pkg{bigfoot} package deeply changes the way footnotes are
%    handled.  When \file{bigfoot} is loaded, we just warn the user
%    that \frenchb{} will not customise footnotes at all.
%    \begin{macrocode}
    \IfPackageLoadedTF{bigfoot}%
      {\FBWarning
          {bigfoot package in use.\MessageBreak
           babel-french will NOT customise footnotes;%
           \MessageBreak reported}}%
%    \end{macrocode}
%    Otherwise, footnotes may be customised according to the
%    \fbsetup{} options.
%    \begin{macrocode}
      {\let\@footnotemarkORI\@footnotemark
       \ifFBAutoSpaceFootnotes
         \let\@footnotemark\@footnotemarkFB
       \fi
       \ifdim\parindentFFN<\maxdimen
       \else
         \parindentFFN=\parindent
         \ifdim\parindentFFN<1.5em \parindentFFN=1.5em \fi
       \fi
       \settowidth{\FBfnindent}{\dotFFN\kernFFN}%
       \addtolength{\FBfnindent}{\parindentFFN}%
       \let\@makefntextORI\@makefntext
%    \end{macrocode}
%    Koma-script classes require a special treatment.\par
%    Definition of |\@makefntext| for koma-script classes: running
%    \@makefntextORI inside a group to reset |\localleftbox{}| and
%    |\FBeverypar@quote| would mess up the layout of footnotes
%    whenever the first manadatory argument of |\deffootnote{}|
%    (used as |\leftskip|) is non-nil (default is 1em, 0pt in French).
%    \begin{macrocode}
       \ifFB@koma
         \let\@@makefnmarkORI\@@makefnmark
         \long\def\@makefntext##1{%
           \localleftbox{}%
           \let\FBeverypar@save\FBeverypar@quote
           \let\FBeverypar@quote\relax
           \ifFBFrenchFootnotes
             \ifx\footnote\thanks
               \let\@@makefnmark\@@makefnmarkTH
               \@makefntextTH{##1}
             \else
               \let\@@makefnmark\@@makefnmarkFB
               \@makefntextFB{##1}
             \fi
           \else
             \let\@@makefnmark\@@makefnmarkORI
             \@makefntextORI{##1}%
           \fi
           \let\FBeverypar@quote\FBeverypar@save
           \localleftbox{\FBeveryline@quote}}%
       \else
%    \end{macrocode}
%    Special add-on for the \cls{memoir} class: |\@makefntext| is
%    redefined as |\makethanksmark| by |\maketitle|, hence these
%    settings to match the other notes’ vertical alignment.
%    \begin{macrocode}
         \IfClassLoadedTF{memoir}%
            {\ifFBFrenchFootnotes
               \setlength{\thanksmarkwidth}{\parindentFFN}%
               \setlength{\thanksmarksep}{-\thanksmarkwidth}%
             \fi
            }{}%
%    \end{macrocode}
%    Special add-on for the \cls{beamer} class: issue a warning
%    in case |\parindentFFN| has been changed.
%    \begin{macrocode}
         \IfClassLoadedTF{beamer}%
            {\ifFBFrenchFootnotes
               \ifdim\parindentFFN=1.5em\else
                 \FBWarning{%
                    \protect\parindentFFN\space is ineffective%
                    \MessageBreak within the beamer class.%
                    \MessageBreak Reported}%
               \fi
             \fi
            }{}%
%    \end{macrocode}
%    Definition of |\@makefntext| for all other classes:
%    \begin{macrocode}
         \long\def\@makefntext##1{%
           \localleftbox{}%
           \let\FBeverypar@save\FBeverypar@quote
           \let\FBeverypar@quote\relax
           \ifFBFrenchFootnotes
             \@makefntextFB{##1}%
           \else
             \@makefntextORI{##1}%
           \fi
           \let\FBeverypar@quote\FBeverypar@save
           \localleftbox{\FBeveryline@quote}}%
       \fi
    }%
  }
%    \end{macrocode}
%
% \changes{v4.0b}{2025-07-01}{\cs{FB@legacyFootnoteSetup} moved to
%    \cs{extrasfrench} (tagging issue).}
%
%    |\FB@legacyFootnoteSetup| is executed when entering French for the
%    first time (at |\begin{document}|), after possible redefinitions
%    made by \file{latex-lab} for tagging.
%    \begin{macrocode}
  \def\bbl@frenchfootnotes{%
    \ifFB@mainlanguage@FR
      \ifFBnewfootnotes
      \else
        \FB@legacyFootnoteSetup
        \let\FB@legacyFootnoteSetup\relax
      \fi
    \fi}
  \addto\extrasfrench{\bbl@frenchfootnotes}
%    \end{macrocode}
%
%    The next two commands are provided only with legacy code.\\
%    |\StandardFootnotes| may be used locally (in minipages for
%    instance), that’s why the test |\ifFBFrenchFootnotes| is done
%    inside |\@makefntext|.
%    \begin{macrocode}
  \newcommand*{\FrenchFootnotes}{\FBFrenchFootnotestrue}
  \newcommand*{\StandardFootnotes}{\FBFrenchFootnotesfalse}
\fi
%    \end{macrocode}
%
%  \subsection{Clean up and exit}
%
% \changes{v3.7a}{2025-05-19}{Support for acadian dropped. The files
%    \file{acadian.ldf}, \file{canadien.ldf}, \file{frenchb.ldf} and
%    \file{francais.ldf} load \file{french.ldf} and print a warning.}
%
%    Final cleaning.
%    The macro |\ldf@finish| takes care for setting the main language
%    to be switched on at |\begin{document}| and resetting the
%    category code of \texttt{@} to its original value. |\loadlocalcfg|
%    is redefined locally in order not to load any \file{.cfg} file for
%    French.
%    \begin{macrocode}
\FBclean@on@exit
\ldf@finish\CurrentOption
\let\loadlocalcfg\FB@llc
%</french>
%    \end{macrocode}
%
% \Finale
%
\endinput

%%% Local Variables:
%%% fill-column: 75
%%% coding: utf-8
%%% mode: doctex
%%% TeX-engine: luatex
%%% End:
