diff options
Diffstat (limited to 'Master/texmf-dist/source/generic/babel/frenchb.dtx')
-rw-r--r-- | Master/texmf-dist/source/generic/babel/frenchb.dtx | 932 |
1 files changed, 695 insertions, 237 deletions
diff --git a/Master/texmf-dist/source/generic/babel/frenchb.dtx b/Master/texmf-dist/source/generic/babel/frenchb.dtx index b8b97f3b0bc..ffdf03fcc99 100644 --- a/Master/texmf-dist/source/generic/babel/frenchb.dtx +++ b/Master/texmf-dist/source/generic/babel/frenchb.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright 1989-2009 Johannes L. Braams and any individual authors +% Copyright 1989-2011 Johannes L. Braams and any individual authors % listed elsewhere in this file. All rights reserved. % % This file is part of the Babel system. @@ -26,7 +26,7 @@ % and covered by LPPL is defined by the unpacking scripts (with % extension .ins) which are part of the distribution. % \fi -% \CheckSum{2135} +% \CheckSum{2599} % % \iffalse % Tell the \LaTeX\ system who we are and write an entry on the @@ -41,25 +41,25 @@ %<code>\ProvidesLanguage{frenchb} %\ProvidesFile{frenchb.dtx} %<*!cfg> - [2009/03/16 v2.3d French support from the babel system] + [2010/08/21 v2.5a French support from the babel system] %</!cfg> %<*cfg> %% frenchb.cfg: configuration file for frenchb.ldf -%% Daniel Flipo Daniel.Flipo at univ-lille1.fr +%% Daniel Flipo daniel.flipo at free.fr %</cfg> %% File `frenchb.dtx' %% Babel package for LaTeX version 2e -%% Copyright (C) 1989 - 2009 +%% Copyright (C) 1989 - 2010 %% by Johannes Braams, TeXniek % %<*!cfg> %% Frenchb language Definition File -%% Copyright (C) 1989 - 2009 +%% Copyright (C) 1989 - 2010 %% by Johannes Braams, TeXniek %% Daniel Flipo, GUTenberg % %% Please report errors to: Daniel Flipo, GUTenberg -%% Daniel.Flipo at univ-lille1.fr +%% daniel.flipo at free.fr %</!cfg> % % This file is part of the babel system, it provides the source @@ -84,7 +84,7 @@ \begin{center} \textbf{\Large A Babel language definition file for French}\\[3mm]^^A\] Daniel \textsc{Flipo}\\ - \texttt{Daniel.Flipo@univ-lille1.fr} + \texttt{daniel.flipo@free.fr} \end{center} \RecordChanges \DocInput{frenchb.dtx} @@ -168,7 +168,7 @@ % \item `double punctuation' (|:| |;| |!| |?|) is made % active%\footnote{Actually, they are active in the whole % document, only their expansions differ in French and -% outside French} for correct spacing in French; +% outside French.} for correct spacing in French; % \item |\today| prints the date in French; % \item the caption names are translated into French % (\LaTeX{} only); @@ -281,7 +281,8 @@ % reverts to the standard settings of |list|. This option % replaces the former command |\FrenchListSpacingfalse|. % \item |CompactItemize=false [true*]|; |frenchb| normally -% suppresses any vertical space between items of |itemize| lists +% redefines the |itemize| environment to +% suppresse any vertical space between items of |itemize| lists % in French; setting this option to |false| reverts to the % standard settings of |itemize| lists. This option replaces % the former command |\FrenchItemizeSpacingfalse|. @@ -367,6 +368,9 @@ % ``Premi\`ere partie~I'', ``Deuxi\`eme partie~II'' instead; % when this occurs, this option should be set to |false|, % part titles will then be printed as ``Partie I'', ``Partie II''. +% \item |SuppressWarning=true [false]|; when true |frenchb| issues +% no warnings if |\@makecaption| has been redefined or if the +% bigfoot package is in use. % \item |og=|\texttt{\guillemotleft}, |fg=|\texttt{\guillemotright}; % when guillemets characters are available on the keyboard % (through a compose key for instance), it is nice to use them @@ -519,6 +523,45 @@ % messages when diacritics are used inside |\up{}| (diacritics % should \emph{never} be used in superscripts though!). % +% \subsubsection*{What's new in version 2.4?} +% +% A new option |SuppressWarning| has been added (desactivated by +% default) to suppress warnings if |\@makecaption| has been +% redefined or if the bigfoot package is in use. +% +% French hyphenation patterns are now coded in Unicode, see file +% \file{hyph-fr.tex}. Extra code has been added to deal with +% hyphenation of the French ``apostrophe'' with XeTeX and LuaTeX +% engines. +% +% Better compatibility with the enumitem package. +% +% When typewriter fonts are in use (hence in verbatim mode) no +% space is added after `\guillemotleft' and before +% `\guillemotright' when they are entered as characters +% (see |\frenchbsetup|). +% +% \subsubsection*{What's new in version 2.5?} +% +% The main change is that active characters are no longer used +% in French with (recent) Xe\TeX-based engines (they still are +% with \TeX-based engines). All the functionalities (automatic +% insertion of missing spaces before |:;!?| or bare replacement +% of typed spaces with suitable unbreabable ones, tuning of the +% spaces width) remain available and the user interface is +% unchanged. The use of active characters is replaced by the +% |\XeTeXinterchartoks| mechanism (as in package +% \file{polyglossia}). +% +% A new command |\NoAutoSpacing| has been added. It should be used +% \emph{inside a group} instead of |\shorthandoff{;:!?}| whenever +% active characters or automatic spacing of French punctuation or +% quote characters conflict with other packages; it is designed to +% work with \TeX- and Xe\TeX-based engines. +% +% Bug correction: \file{frenchb.ldf} no longer messes up +% |\frenchspacing| and |\nonfrenchspacing| in other languages. +% % \StopEventually{} % % \subsection{File frenchb.cfg} @@ -536,7 +579,7 @@ %% If you want to customise frenchb, please DO NOT hack into the code! %% Do no put any code in this file either, please use the new command %% \frenchbsetup{} with the proper options to customise frenchb. -%% +%% %% Add \frenchbsetup{ShowOptions} to your preamble to see the list of %% available options and/or read the documentation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -545,8 +588,6 @@ %</cfg> % \fi % -% \section{\TeX{}nical details} -% % \subsection{Initial setup} % % \changes{v2.1d}{2008/05/02}{Argument of \cs{ProvidesLanguage} changed @@ -676,34 +717,60 @@ % of those expressions, and has to be reset to null when exiting % French. % +% \changes{v2.4a}{2009/11/23}{Added a new `if' \cs{FBunicode} and +% some \cs{lccode} definitions to \cs{extrasfrench} and +% \cs{noextrasfrench}.} +% +% French hyphenation patterns are now coded in Unicode, see file +% \file{hyph-fr.tex}. XeTeX and LuaTeX engines require some extra +% code to deal with the French ``apostrophe''. +% Let's define a new `if' |\FBunicode| which will be true for XeTeX +% and LuaTeX engines and false for 8-bits engines. +% % \begin{macrocode} -\@namedef{extras\CurrentOption}{\lccode`\'=`\'} -\@namedef{noextras\CurrentOption}{\lccode`\'=0} +\newif\ifFBunicode +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname luatexversion\endcsname\relax +\else + \FBunicodetrue +\fi +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname XeTeXrevision\endcsname\relax +\else + \FBunicodetrue +\fi +\@namedef{extras\CurrentOption}{\lccode`\'=`\' + \ifFBunicode\lccode"2019="2019\fi} +\@namedef{noextras\CurrentOption}{\lccode`\'=0 + \ifFBunicode\lccode"2019=0\fi} % \end{macrocode} % \end{macro} % \end{macro} % % One more thing |\extrasfrench| needs to do is to make sure that -% |\frenchspacing| is in effect. |\noextrasfrench| will switch -% |\frenchspacing| off again. +% ``Frenchspacing'' is in effect. |\noextrasfrench| will switch +% ``Frenchspacing'' off again if necessary. % \begin{macrocode} - \expandafter\addto\csname extras\CurrentOption\endcsname{% - \bbl@frenchspacing} - \expandafter\addto\csname noextras\CurrentOption\endcsname{% - \bbl@nonfrenchspacing} +\addto\extrasfrench{\bbl@frenchspacing} +\addto\noextrasfrench{\bbl@nonfrenchspacing} % \end{macrocode} % % \subsection{Punctuation} % \label{sec-punct} % -% As long as no better solution is available% -% \footnote{Lua\TeX, or pdf\TeX{} might provide alternatives in -% the future\dots}, -% the `double punctuation' characters (|;| |!| |?| and |:|) have to -% be made |\active| for an automatic control of the amount of space -% to insert before them. Before doing so, we have to save the -% standard definition of |\@makecaption| (which includes two ':') -% to compare it later to its definition at the |\begin{document}|. +% \changes{v2.5a}{2010/08/10}{Punctation is no longer made active +% with XeTeX-based engines.} +% +% As long as no better solution is available, the `double +% punctuation' characters (|;| |!| |?| and |:|) have to be made +% |\active| for an automatic control of the amount of space to +% insert before them. Xe\TeX{} provides an alternative to active +% characters and Lua\TeX{} will hopefully do so as well in the +% (near?) future. +% +% Before doing so, we have to save the standard definition of +% |\@makecaption| (which includes two ':') to compare it later to +% its definition at the |\begin{document}|. % \begin{macrocode} \long\def\STD@makecaption#1#2{% \vskip\abovecaptionskip @@ -714,24 +781,200 @@ \global \@minipagefalse \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% \fi - \vskip\belowcaptionskip}% + \vskip\belowcaptionskip} % \end{macrocode} % -% We define a new `if' |\FBpunct@active| which will be made false -% whenever a better alternative will be available. Another `if' -% |\FBAutoSpacePunctuation| needs to be defined now. +% \changes{v2.5a}{2010/08/10}{Define \cs{Fthinspace} for those who want +% to customise the width of the space before ; ! and ?.} +% +% According to the I.N. specifications, the `:' requires a normal +% space before it, but some people prefer a |\thinspace| (just +% like the other three). We define |\Fcolonspace| to hold the +% required amount of space (user customisable). In case some users +% are not satisfied with |\thinspace|'s width, it is also +% customisable. % \begin{macrocode} -\newif\ifFBpunct@active \FBpunct@activetrue -\newif\ifFBAutoSpacePunctuation \FBAutoSpacePunctuationtrue +\newcommand*{\Fcolonspace}{\space} +\newcommand*{\Fthinspace}{\thinspace} +% \end{macrocode} +% +% Check the availability of |\XeTeXinterchartokenstate| and decide +% whether the `double punctuation' characters (|;| |!| |?| and |:|) +% have to be made |\active| or not. +% \begin{macrocode} +\newif\ifFB@active@punct \FB@active@puncttrue +\newif\ifFB@xetex@punct +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname XeTeXinterchartokenstate\endcsname\relax +\else + \FB@xetex@puncttrue\FB@active@punctfalse +\fi +% \end{macrocode} +% +% If |\XeTeXinterchartokenstate| is available, we use the +% ``inter char'' mechanism (as in polyglossia, see +% \file{gloss-french.ldf}) to provide correct spacing in French +% before the four characters |;| |!| |?| and |:| and for French +% quotes (\texttt{\guillemotleft} and \texttt{\guillemotright}). +% +% It is assumed that for every character used in French text-mode +% (except spaces), |\XeTeXcharclass| value is 0 before entering +% French. |\XeTeXcharclass| value for spaces is assumed to be 255. +% Otherwise, the spacing before the `double punctuation' characters +% will not be correct. +% +% We switch |\XeTeXinterchartokenstate| to 1 and change the +% |\XeTeXcharclass| values of |;| |!| |?| |:| |(| |]| +% \texttt{\guillemotleft} and \texttt{\guillemotright} when +% entering French. Special care is taken to restore them to their +% inital values when leaving French. +% \begin{macrocode} +\newif\ifFBAutoSpaceGuill \FBAutoSpaceGuilltrue +\ifFB@xetex@punct + \PackageInfo{frenchb.ldf}{No need for active punctuation characters + \MessageBreak with this version of XeTeX! reported} +% \end{macrocode} +% We will need the following code (borrowed from +% \file{zhsusefulmacros.sty}) for loops: +% \begin{macrocode} + \@ifundefined{@for}{% + \def\@nnil{\@nil}% + \def\@empty{}% + \def\@fornoop#1\@@#2#3{}% + \long\def\@for#1:=#2\do#3{% + \expandafter\def\expandafter\@fortmp\expandafter{#2}% + \ifx\@fortmp\@empty \else + \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}% + \long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else + #5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi}% + \long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil + \expandafter\@fornoop \else + #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}% + \def\@tfor#1:={\@tf@r#1 }% + \long\def\@tf@r#1#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\space\else + \@tforloop#2\@nil\@nil\@@#1{#3}\fi}% + \long\def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil + \expandafter\@fornoop \else + #4\relax\expandafter\@tforloop\fi#2\@@#3{#4}}% + }{}% +% \end{macrocode} +% New character classes, +% \begin{macrocode} + \newcount\FB@interchartokenstateORI + \newXeTeXintercharclass\FB@punctthick + \newXeTeXintercharclass\FB@punctthin + \newXeTeXintercharclass\FB@punctnul + \newXeTeXintercharclass\FB@punctguilo + \newXeTeXintercharclass\FB@punctguilf +% \end{macrocode} +% We define a command to store the |\XeTeXcharclass| values which +% will be modified for French (as a comma separated list) and a +% command to retrieve them. +% \begin{macrocode} +% \newcommand*{\FB@charclassesORI}{} + \def\FB@charclassesORI{} + \def\empty{} + \def\FB@parse#1,#2\endparse{\def\FB@class{#1}% + \def\FB@charclassesORI{#2}}% +% \end{macrocode} +% +% The following command will be executed when entering French, it +% first saves the values to be modified, then fits them to our +% needs. It also redefines |\shorthandoff| and |\shorthandon| +% (locally) to avoid error messages with XeTeX-based engines. +% \begin{macrocode} + \newcommand*{\FB@xetex@punct@french}{% +% \end{macrocode} +% Saving must not be repeated if saved values are already in. +% \begin{macrocode} + \ifx\FB@charclassesORI\empty + \FB@interchartokenstateORI=\XeTeXinterchartokenstate + \@for\FB@char:={`\:,`\;,`\!,`\?,`\[,`\(,"00AB,"00BB}\do + {\edef\FB@charclassesORI{\FB@charclassesORI% + \the\XeTeXcharclass\FB@char,}}% + \let\shorthandonORI\shorthandon + \let\shorthandoffORI\shorthandoff + \fi % \end{macrocode} -% The following code makes the four characters |;| |!| |?| and |:| -% `active' and provides their definitions. +% Set the classes and interactions between classes. +% \begin{macrocode} + \XeTeXinterchartokenstate=1 + \XeTeXcharclass `\: = \FB@punctthick + \XeTeXinterchartoks \z@ \FB@punctthick = {% + \ifhmode\FDP@colonspace\fi}% + \XeTeXinterchartoks \FB@punctguilf \FB@punctthick = {% + \FDP@colonspace}% + \XeTeXinterchartoks 255 \FB@punctthick = {% + \ifhmode\unskip\penalty\@M\Fcolonspace\fi}% + \@for\FB@char:={`\;,`\!,`\?}\do + {\XeTeXcharclass\FB@char=\FB@punctthin}% + \XeTeXinterchartoks \z@ \FB@punctthin = {% + \ifhmode\FDP@thinspace\fi}% + \XeTeXinterchartoks \FB@punctguilf \FB@punctthin = {% + \FDP@thinspace}% + \XeTeXinterchartoks 255 \FB@punctthin = {% + \ifhmode\unskip\penalty\@M\Fthinspace\fi}% +% \end{macrocode} +% This avoids spurious spaces in (!), (???), etc. +% \begin{macrocode} + \@for\FB@char:={`\[,`\(}\do + {\XeTeXcharclass\FB@char=\FB@punctnul}% + \XeTeXinterchartoks \FB@punctnul \FB@punctthin = {}% + \XeTeXcharclass"00AB = \FB@punctguilo + \XeTeXinterchartoks \FB@punctguilo \z@ = {% + \ifFBAutoSpaceGuill\FBguill@spacing\fi}% + \XeTeXinterchartoks \FB@punctguilo 255 = {% + \ifFBAutoSpaceGuill\FBguill@spacing\ignorespaces\fi}% + \XeTeXcharclass"00BB = \FB@punctguilf + \XeTeXinterchartoks \z@ \FB@punctguilf = {% + \ifFBAutoSpaceGuill\FBguill@spacing\fi}% + \XeTeXinterchartoks \FB@punctthin \FB@punctguilf = {% + \ifFBAutoSpaceGuill\FBguill@spacing\fi}% + \XeTeXinterchartoks 255 \FB@punctguilf = {% + \ifFBAutoSpaceGuill\unskip\FBguill@spacing\fi}% +% \end{macrocode} +% With Xe(La)TeX, French defines no active shorthands. +% \begin{macrocode} + \def\shorthandoff##1{% + \PackageWarning{frenchb.ldf}{\protect\shorthandoff{;:!?} is + helpless with XeTeX,\MessageBreak use \protect\NoAutoSpacing + \space *inside a group* instead;\MessageBreak reported}% + }% + \def\shorthandon##1{}% + } +% \end{macrocode} +% +% The following command will be executed when leaving French for +% restoring values and commands modified in French. +% When French is not the main language, |\noextrasfrench| is +% executed `AtBeginDocument', so the test on +% |\FB@charclassesORI| is mandatory. % \begin{macrocode} -\ifFBpunct@active - \initiate@active@char{:} - \initiate@active@char{;} - \initiate@active@char{!} - \initiate@active@char{?} + \newcommand*{\FB@xetex@punct@nonfrench}{% + \ifx\FB@charclassesORI\empty + \else + \@for\FB@char:={`\:,`\;,`\!,`\?,`\[,`\(,"00AB,"00BB}\do + {\expandafter\FB@parse\FB@charclassesORI\endparse + \XeTeXcharclass\FB@char=\FB@class}% + \def\FB@charclassesORI{}% + \XeTeXinterchartokenstate=\FB@interchartokenstateORI + \let\shorthandon\shorthandonORI + \let\shorthandoff\shorthandoffORI + \fi + } + \addto\extrasfrench{\FB@xetex@punct@french} + \addto\noextrasfrench{\FB@xetex@punct@nonfrench} +\fi +% \end{macrocode} +% +% Otherwise we need to make the four characters |;| |!| |?| and |:| +% `active' and provide their definitions. +% \begin{macrocode} +\ifFB@active@punct + \initiate@active@char{:}% + \initiate@active@char{;}% + \initiate@active@char{!}% + \initiate@active@char{?}% % \end{macrocode} % We first tune the amount of space before \texttt{;} % \texttt{!} \texttt{?} and \texttt{:}. This should only happen @@ -746,7 +989,7 @@ \declare@shorthand{french}{;}{% \ifhmode \ifdim\lastskip>\z@ - \unskip\penalty\@M\thinspace + \unskip\penalty\@M\Fthinspace \else \FDP@thinspace \fi @@ -761,7 +1004,7 @@ \declare@shorthand{french}{!}{% \ifhmode \ifdim\lastskip>\z@ - \unskip\penalty\@M\thinspace + \unskip\penalty\@M\Fthinspace \else \FDP@thinspace \fi @@ -770,19 +1013,12 @@ \declare@shorthand{french}{?}{% \ifhmode \ifdim\lastskip>\z@ - \unskip\penalty\@M\thinspace + \unskip\penalty\@M\Fthinspace \else \FDP@thinspace \fi \fi \string?} -% \end{macrocode} -% According to the I.N. specifications, the `:' requires a normal -% space before it, but some people prefer a |\thinspace| (just -% like the other three). We define |\Fcolonspace| to hold the -% required amount of space (user customisable). -% \begin{macrocode} - \newcommand*{\Fcolonspace}{\space} \declare@shorthand{french}{:}{% \ifhmode \ifdim\lastskip>\z@ @@ -793,35 +1029,72 @@ \fi \string:} % \end{macrocode} +% When the active characters appear in an environment where their +% French behaviour is not wanted they should give an `expected' +% result. Therefore we define shorthands at system level as well. +% \begin{macrocode} + \declare@shorthand{system}{:}{\string:} + \declare@shorthand{system}{!}{\string!} + \declare@shorthand{system}{?}{\string?} + \declare@shorthand{system}{;}{\string;} +%} +% \end{macrocode} +% We specify that the French group of shorthands should be used when +% switching to French. +% \begin{macrocode} + \addto\extrasfrench{% + \languageshorthands{french}% +% \end{macrocode} +% These characters are `turned on' once, later their definition may +% vary. Don't misunderstand the following code: they keep being +% active all along the document, even when leaving French. +% \begin{macrocode} + \bbl@activate{:}\bbl@activate{;}% + \bbl@activate{!}\bbl@activate{?}% + } + \addto\noextrasfrench{% + \bbl@deactivate{:}\bbl@deactivate{;}% + \bbl@deactivate{!}\bbl@deactivate{?}} +\fi +% \end{macrocode} +% +% A new `if' |\FBAutoSpacePunctuation| needs to be defined now. +% \begin{macrocode} +\newif\ifFBAutoSpacePunctuation \FBAutoSpacePunctuationtrue +% \end{macrocode} % % \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.} +% % \begin{macro}{\AutoSpaceBeforeFDP} % \begin{macro}{\NoAutoSpaceBeforeFDP} -% |\FDP@thinspace| and |\FDP@space| are defined as unbreakable +% |\FDP@thinspace| and |\FDP@colonspace| are defined as unbreakable % spaces by |\autospace@beforeFDP| or as |\@empty| by % |\noautospace@beforeFDP| (internal commands), user commands % |\AutoSpaceBeforeFDP| and |\NoAutoSpaceBeforeFDP| do the same and % take care of the flag |\ifFBAutoSpacePunctuation| in \LaTeX{}. % Set the default now for Plain (done later for \LaTeX). % \begin{macrocode} - \def\autospace@beforeFDP{% - \def\FDP@thinspace{\penalty\@M\thinspace}% +\def\autospace@beforeFDP{% + \def\FDP@thinspace{\penalty\@M\Fthinspace}% \def\FDP@colonspace{\penalty\@M\Fcolonspace}} - \def\noautospace@beforeFDP{\let\FDP@thinspace\@empty +\def\noautospace@beforeFDP{\let\FDP@thinspace\@empty \let\FDP@colonspace\@empty} - \ifLaTeXe +\ifLaTeXe \def\AutoSpaceBeforeFDP{\autospace@beforeFDP \FBAutoSpacePunctuationtrue} \def\NoAutoSpaceBeforeFDP{\noautospace@beforeFDP \FBAutoSpacePunctuationfalse} - \else +\else \let\AutoSpaceBeforeFDP\autospace@beforeFDP \let\NoAutoSpaceBeforeFDP\noautospace@beforeFDP - \AutoSpaceBeforeFDP \fi +\AutoSpaceBeforeFDP % \end{macrocode} % \end{macro} % \end{macro} @@ -843,56 +1116,59 @@ % % These redefinitions can be canceled if necessary, for instance to % recompile older documents, see option |OriginalTypewriter| below. +% +% \changes{v2.4c}{2010/05/23}{In \cs{ttfamilyFB}, also cancel +% automatic spaces inside French guillemets entered as characters +% (see \cs{frenchbsetup}).} +% +% To be consistent with what is done for `double punctuation' +% characters, |\ttfamilyFB| also switches off insertion of spaces +% inside French guillemets \emph{when they are typed in as +% characters} with the `og'/`fg' option in |\frenchbsetup{}|. +% This is also a workaround for the weird behaviour of these +% characters in verbatim mode. % \begin{macrocode} - \ifLaTeXe +\ifLaTeXe \let\ttfamilyORI\ttfamily \let\rmfamilyORI\rmfamily \let\sffamilyORI\sffamily \DeclareRobustCommand\ttfamilyFB{% + \FBAutoSpaceGuillfalse \noautospace@beforeFDP\ttfamilyORI}% \DeclareRobustCommand\rmfamilyFB{% + \FBAutoSpaceGuilltrue \ifFBAutoSpacePunctuation - \autospace@beforeFDP\rmfamilyORI + \autospace@beforeFDP\rmfamilyORI \else - \noautospace@beforeFDP\rmfamilyORI + \noautospace@beforeFDP\rmfamilyORI \fi}% \DeclareRobustCommand\sffamilyFB{% + \FBAutoSpaceGuilltrue \ifFBAutoSpacePunctuation - \autospace@beforeFDP\sffamilyORI + \autospace@beforeFDP\sffamilyORI \else - \noautospace@beforeFDP\sffamilyORI + \noautospace@beforeFDP\sffamilyORI \fi}% - \fi +\fi % \end{macrocode} % -% When the active characters appear in an environment where their -% French behaviour is not wanted they should give an `expected' -% result. Therefore we define shorthands at system level as well. -% \begin{macrocode} - \declare@shorthand{system}{:}{\string:} - \declare@shorthand{system}{!}{\string!} - \declare@shorthand{system}{?}{\string?} - \declare@shorthand{system}{;}{\string;} -% \end{macrocode} -% We specify that the French group of shorthands should be used. +% \changes{v2.5a}{2010/08/14}{New command \cs{NoAutoSpacing}, +% suggested by MPG.} +% +% The following command will switch off active punctuation +% characters (if any) and disable automatic spacing for French quote +% characters. It is engine independent (works for \TeX{} and +% Xe\TeX{} based engines) and is meant to be used inside a group. +% \begin{macro}{\NoAutoSpacing} % \begin{macrocode} - \addto\extrasfrench{% - \languageshorthands{french}% -% \end{macrocode} -% These characters are `turned on' once, later their definition may -% vary. Don't misunderstand the following code: they keep being -% active all along the document, even when leaving French. -% \begin{macrocode} - \bbl@activate{:}\bbl@activate{;}% - \bbl@activate{!}\bbl@activate{?}% - } - \addto\noextrasfrench{% - \bbl@deactivate{:}\bbl@deactivate{;}% - \bbl@deactivate{!}\bbl@deactivate{?}} -\fi +\newcommand*{\NoAutoSpacing}{\FBAutoSpaceGuillfalse + \ifFB@active@punct\shorthandoff{;:!?}\fi + \ifFB@xetex@punct\XeTeXinterchartokenstate=0\fi} % \end{macrocode} +% \end{macro} % -% \subsection{French quotation marks} +% \subsection{Commands for French quotation marks} +% \label{sec-quotes} % % \begin{macro}{\og} % \begin{macro}{\fg} @@ -900,7 +1176,8 @@ % (``\underline{o}uvrez \underline{g}uillemets'') and |\fg| % (``\underline{f}ermez \underline{g}uillemets''). % Another option for typesetting quotes in multilingual texts -% is to use the package |csquotes.sty| and its command |\enquote|. +% is to use the package \file{csquotes.sty} and its command +% |\enquote|. % % \begin{macrocode} \newcommand*{\og}{\@empty} @@ -911,6 +1188,8 @@ % % \begin{macro}{\guillemotleft} % \begin{macro}{\guillemotright} +% \begin{macro}{\textquoteddblleft} +% \begin{macro}{\textquoteddblright} % \LaTeX{} users are supposed to use 8-bit output encodings (T1, % LY1,\dots) to typeset French, those who still stick to OT1 should % call |aeguill.sty| or a similar package. In both cases the @@ -921,24 +1200,37 @@ % We will check `AtBeginDocument' that the proper output encodings % are in use (see end of section~\ref{sec-keyval}). % -% We give the following definitions for Plain users only as a (poor) +% \changes{v2.5a}{2010/08/20}{Change \cs{guillemotleft} and +% \cs{guillemotright} definitions for Unicode anf provide +% definitions for \cs{textquotedblleft} and +% \cs{textquotedbright}. Insures correct printing of quotes +% by \cs{og} and \cs{fg} in French and outside.} + +% We give the following definitions for non-LaTeX users only as a % fall-back, they are welcome to change them for anything better. % \begin{macrocode} \ifLaTeXe \else - \ifx\guillemotleft\@undefined + \ifFBunicode + \def\guillemotleft{\char"00AB} + \def\guillemotright{\char"00BB} + \def\textquotedblleft{\char"201C} + \def\textquotedblright{\char"201D} + \else \def\guillemotleft{\leavevmode\raise0.25ex \hbox{$\scriptscriptstyle\ll$}} - \fi - \ifx\guillemotright\@undefined \def\guillemotright{\raise0.25ex \hbox{$\scriptscriptstyle\gg$}} + \def\textquotedblleft{``} + \def\textquotedblright{''} \fi \let\xspace\relax \fi % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % The next step is to provide correct spacing after |\guillemotleft| % and before |\guillemotright|: a space precedes and follows @@ -948,7 +1240,7 @@ % Thierry Bouche. French quotes (including spacing) are printed by % |\FB@og| and |\FB@fg|, the expansion of the top level commands % |\og| and |\og| is different in and outside French. -% We'll try to be smart to users of David~Carlisle's |xspace| +% We'll try to be smart to users of David~Carlisle's \file{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). @@ -957,10 +1249,11 @@ \newcommand*{\FBguill@spacing}{\penalty\@M\hskip.8\fontdimen2\font plus.3\fontdimen3\font minus.8\fontdimen4\font} -\DeclareRobustCommand*{\FB@og}{\leavevmode - \guillemotleft\FBguill@spacing} +\DeclareRobustCommand*{\FB@og}{\leavevmode\guillemotleft + \ifFB@xetex@punct\else\FBguill@spacing\fi} \DeclareRobustCommand*{\FB@fg}{\ifdim\lastskip>\z@\unskip\fi - \FBguill@spacing\guillemotright\xspace} + \ifFB@xetex@punct\else\FBguill@spacing\fi + \guillemotright\xspace} % \end{macrocode} % % The top level definitions for French quotation marks are switched @@ -968,6 +1261,10 @@ % mechanism. Outside French, |\og| and |\fg| will typeset standard % English opening and closing double quotes. % +% \changes{v2.5a}{2010/08/20}{\cs{og} and \cs{fg} do not print +% correctly in English when using XeTeX, fixed by using +% \cs{textquotedblleft} and \cs{textquotedblright} defined above.} +% % \begin{macrocode} \ifLaTeXe \def\bbl@frenchguillemets{\renewcommand*{\og}{\FB@og}% @@ -976,15 +1273,13 @@ \renewcommand*{\fg}{\ifdim\lastskip>\z@\unskip\fi \textquotedblright}} \else - \def\bbl@frenchguillemets{\let\og\FB@og - \let\fg\FB@fg} - \def\bbl@nonfrenchguillemets{\def\og{``}% - \def\fg{\ifdim\lastskip>\z@\unskip\fi ''}} + \def\bbl@frenchguillemets{\let\og\FB@og + \let\fg\FB@fg} + \def\bbl@nonfrenchguillemets{\def\og{\textquotedblleft}% + \def\fg{\ifdim\lastskip>\z@\unskip\fi\textquotedblright}} \fi -\expandafter\addto\csname extras\CurrentOption\endcsname{% - \bbl@frenchguillemets} -\expandafter\addto\csname noextras\CurrentOption\endcsname{% - \bbl@nonfrenchguillemets} +\addto\extrasfrench{\bbl@frenchguillemets} +\addto\noextrasfrench{\bbl@nonfrenchguillemets} % \end{macrocode} % % \subsection{Date in French} @@ -999,13 +1294,16 @@ % \changes{v2.1a}{2008/03/25}{\cs{today} changed (correction in 2.0 % was wrong: \cs{today} was printed without spaces in toc).} % +% \changes{v2.5a}{2010/08/20}{Replaced \cs{'}e and \cs{\char94}u +% by c.s. to work with XeTeX.} +% % \begin{macrocode} \@namedef{date\CurrentOption}{% \def\today{{\number\day}\ifnum1=\day {\ier}\fi \space \ifcase\month - \or janvier\or f\'evrier\or mars\or avril\or mai\or juin\or - juillet\or ao\^ut\or septembre\or octobre\or novembre\or - d\'ecembre\fi + \or janvier\or f{\FBeacute}vrier\or mars\or avril\or mai\or + juin\or juillet\or ao{\FBucirconflexe}t\or septembre\or + octobre\or novembre\or d{\FBeacute}cembre\fi \space \number\year}} % \end{macrocode} % \end{macro} @@ -1023,6 +1321,16 @@ % (hyperref safe) of \cs{up} in case it has to be expanded in % the preamble (by beamer's \cs{title} command for instance).} % +% \changes{v2.4d}{2010/07/28}{Command \cs{up} defined with +% \cs{providecommand} instead of \cs{newcommand} as \cs{up} may be +% defined elsewhere (catalan.ldf). +% Bug pointed out by Felip Many\'e i Ballester.} +% +% \changes{v2.5a}{2010/08/21}{Test \cs{@ifundefined} leaves the +% tested control sequence defined as \cs{relax} when TRUE. +% Changed \cs{relax} to \cs{undefined} when testing +% \cs{realsuperscript}.} +% % \begin{macro}{\fup} % % \changes{v2.1b}{2008/04/02}{Command \cs{fup} changed to use @@ -1136,20 +1444,20 @@ % \begin{macrocode} \DeclareRobustCommand*{\fup}[1]{% \@ifundefined{realsuperscript}% - {\FB@up{#1}}% + {\FB@up{#1}\let\realsuperscript\undefined}% {\bgroup\let\fakesuperscript\FB@up@fake \realsuperscript{\FB@lc{#1}}\egroup}} % \end{macrocode} -% Temporary definition of |up| (redefined `AtBeginDocument'). +% Temporary definition of |\up|, redefined `AtBeginDocument'as +% |\fup| or |\textsuperscript| later on while processing the options +% of |\frenchbsetup{}|. % \begin{macrocode} - \newcommand*{\up}{\relax} + \providecommand*{\up}{\relax} % \end{macrocode} -% Poor man's definition of |\up| for Plain. In \LaTeXe, -% |\up| will be defined as |\fup| or |\textsuperscript| later on -% while processing the options of |\frenchbsetup{}|. +% Poor man's definition of |\up| for Plain. % \begin{macrocode} \else - \newcommand*{\up}[1]{\leavevmode\raise1ex\hbox{\sevenrm #1}} + \providecommand*{\up}[1]{\leavevmode\raise1ex\hbox{\sevenrm #1}} \fi % \end{macrocode} % \end{macro} @@ -1275,6 +1583,32 @@ \fi % \end{macrocode} % +% \changes{v2.5a}{2010/08/20}{New definitions needed for XeTeX to print +% properly some dates and captions: using c.s. like \cs{'e} do not +% work with XeTeX (OK with XeLaTeX).} +% +% French dates and captions make use of four non-ascii characters +% (\texttt{\`a}, \texttt{\`e}, \texttt{\'e} and \texttt{\^u}). +% This is fine except for (plain) XeTeX (|\accent| commands are not +% implemented), so we define four new commands to deal with this +% issue; we also redefine |\degre| (it is an accent in LaTeX). +% \begin{macrocode} +\newcommand*{\FBagrave}{\`a} +\newcommand*{\FBegrave}{\`e} +\newcommand*{\FBeacute}{\'e} +\newcommand*{\FBucirconflexe}{\^u} +\ifFBunicode + \ifLaTeXe + \else + \def\degre{\char"00B0} + \def\FBagrave{\char"00E0} + \def\FBegrave{\char"00E8} + \def\FBeacute{\char"00E9} + \def\FBucirconflexe{\char"00FB} + \fi +\fi +% \end{macrocode} +% % \begin{macro}{\degres} % We now define a macro |\degres| for typesetting the abbreviation % for `degrees' (as in `degrees Celsius'). As the bounding box of @@ -1305,12 +1639,13 @@ \MessageBreak add \protect \usepackage{textcomp} to the preamble. \MessageBreak Degrees used}} + \ifFBunicode\global\let\Warning@degree@TSone\relax\fi \AtBeginDocument{\expandafter\ifx\csname M@TS1\endcsname\relax \DeclareRobustCommand*{\degres}{% \leavevmode\hbox to 0.3em{\hss\degre\hss}% \Warning@degree@TSone \global\let\Warning@degree@TSone\relax}% - \let\textdegree\degres + \let\textdegree\degres \else \DeclareRobustCommand*{\degres}{% \hbox{\UseTextSymbol{TS1}{\textdegree}}}% @@ -1347,11 +1682,10 @@ \advance\dec@mcc by -\@tempcnta \newcommand*{\DecimalMathComma}{\iflanguage{french}% {\mathcode`\,=\dec@mcc}{}% - \addto\extrasfrench{\mathcode`\,=\dec@mcc}} + \addto\extrasfrench{\mathcode`\,=\dec@mcc}} \newcommand*{\StandardMathComma}{\mathcode`\,=\std@mcc - \addto\extrasfrench{\mathcode`\,=\std@mcc}} -\expandafter\addto\csname noextras\CurrentOption\endcsname{% - \mathcode`\,=\std@mcc} + \addto\extrasfrench{\mathcode`\,=\std@mcc}} +\addto\noextrasfrench{\mathcode`\,=\std@mcc} % \end{macrocode} % \end{macro} % \end{macro} @@ -1360,7 +1694,7 @@ % % \changes{v2.0}{2006/11/06}{\cs{nombre} requires now numprint.sty.} % -% The command |\nombre| is now borrowed from |numprint.sty| for +% The command |\nombre| is now borrowed from \file{numprint.sty} for % \LaTeXe. There is no point to maintain the former tricky code % when a package is dedicated to do the same job and more. % For Plain based formats, |\nombre| no longer formats numbers, @@ -1379,9 +1713,9 @@ % % \begin{macrocode} \let\FBstop@here\relax -\def\FBclean@on@exit{\let\ifLaTeXe\@undefined - \let\LaTeXetrue\@undefined - \let\LaTeXefalse\@undefined} +\def\FBclean@on@exit{\let\ifLaTeXe\undefined + \let\LaTeXetrue\undefined + \let\LaTeXefalse\undefined} \ifx\magnification\@undefined \else \def\FBstop@here{\let\STD@makecaption\relax @@ -1394,10 +1728,15 @@ % What follows now is for \LaTeXe{} \emph{only}. % We redefine |\nombre| for \LaTeXe. A warning is issued % at the first call of |\nombre| if |\numprint| is not -% defined, suggesting what to do. The package |numprint| +% defined, suggesting what to do. The package \file{numprint} % is \emph{not} loaded automatically by |frenchb| because of % possible options conflict. % +% \changes{v2.5a}{2010/08/21}{Test \cs{@ifundefined} leaves the +% tested control sequence defined as \cs{relax} when TRUE. +% Changed \cs{relax} to \cs{undefined} when testing +% \cs{numprint}.} +% % \begin{macrocode} \renewcommand*{\nombre}[1]{\Warning@nombre\numprint{#1}} \newcommand*{\Warning@nombre}{% @@ -1410,7 +1749,7 @@ see file numprint.pdf for other options.\MessageBreak \protect\nombre\space called}% \global\let\Warning@nombre\relax - \global\let\numprint\relax + \global\let\numprint\undefined }{}% } % \end{macrocode} @@ -1446,15 +1785,22 @@ % \cs{extrasfrench} now instead of \cs{captionsfrench} % because it has to be reset when leaving French.} % +% \changes{v2.5a}{2010/08/16}{\cs{emph} deleted in \cs{seename} +% and \cs{alsoname} to match what is done for the other languages. +% Suggested by Marc Baudoin.} +% +% \changes{v2.5a}{2010/08/20}{Replaced \cs{'e}, \cs{`e} and \cs{`a} +% by c.s. to work with XeTeX.} +% % \begin{macrocode} \@namedef{captions\CurrentOption}{% - \def\refname{R\'ef\'erences}% - \def\abstractname{R\'esum\'e}% + \def\refname{R{\FBeacute}f{\FBeacute}rences}% + \def\abstractname{R{\FBeacute}sum{\FBeacute}}% \def\bibname{Bibliographie}% - \def\prefacename{Pr\'eface}% + \def\prefacename{Pr{\FBeacute}face}% \def\chaptername{Chapitre}% \def\appendixname{Annexe}% - \def\contentsname{Table des mati\`eres}% + \def\contentsname{Table des mati{\FBegrave}res}% \def\listfigurename{Table des figures}% \def\listtablename{Liste des tableaux}% \def\indexname{Index}% @@ -1464,19 +1810,23 @@ % ``Premi\`ere partie'' instead of ``Part I''. % \begin{macrocode} \def\partname{\protect\@Fpt partie}% - \def\@Fpt{{\ifcase\value{part}\or Premi\`ere\or Deuxi\`eme\or - Troisi\`eme\or Quatri\`eme\or Cinqui\`eme\or Sixi\`eme\or - Septi\`eme\or Huiti\`eme\or Neuvi\`eme\or Dixi\`eme\or Onzi\`eme\or - Douzi\`eme\or Treizi\`eme\or Quatorzi\`eme\or Quinzi\`eme\or - Seizi\`eme\or Dix-septi\`eme\or Dix-huiti\`eme\or Dix-neuvi\`eme\or - Vingti\`eme\fi}\space\def\thepart{}}% + \def\@Fpt{{\ifcase\value{part}\or Premi{\FBegrave}re\or + Deuxi{\FBegrave}me\or Troisi{\FBegrave}me\or + Quatri{\FBegrave}me\or Cinqui{\FBegrave}me\or + Sixi{\FBegrave}me\or Septi{\FBegrave}me\or Huiti{\FBegrave}me\or + Neuvi{\FBegrave}me\or Dixi{\FBegrave}me\or Onzi{\FBegrave}me\or + Douzi{\FBegrave}me\or Treizi{\FBegrave}me\or + Quatorzi{\FBegrave}me\or Quinzi{\FBegrave}me\or + Seizi{\FBegrave}me\or Dix-septi{\FBegrave}me\or + Dix-huiti{\FBegrave}me\or Dix-neuvi{\FBegrave}me\or + Vingti{\FBegrave}me\fi}\space\def\thepart{}}% \def\pagename{page}% - \def\seename{{\emph{voir}}}% - \def\alsoname{{\emph{voir aussi}}}% + \def\seename{voir}% + \def\alsoname{voir aussi}% \def\enclname{P.~J. }% - \def\ccname{Copie \`a }% + \def\ccname{Copie {\FBagrave} }% \def\headtoname{}% - \def\proofname{D\'emonstration}% + \def\proofname{D{\FBeacute}monstration}% \def\glossaryname{Glossaire}% } % \end{macrocode} @@ -1537,7 +1887,13 @@ % If the definitions differ, |frenchb| doesn't overwrite the changes, % but prints a message in the .log file. % +% \changes{v2.4a}{2009/11/23}{\cs{PackageWarning} changed to +% \cs{FBWarning} (in case \cs{@makecaption} has been customized). +% \cs{FBWarning} is defined as \cs{PackageWarning} by default but +% can be made silent using \cs{frenchbsetup}, (suggested by MPG).} +% % \begin{macrocode} +\newcommand{\FBWarning}[2]{\PackageWarning{#1}{#2}} \def\CaptionSeparator{\string:\space} \long\def\FB@makecaption#1#2{% \vskip\abovecaptionskip @@ -1553,8 +1909,9 @@ \ifx\@makecaption\STD@makecaption \global\let\@makecaption\FB@makecaption \else - \@ifundefined{@makecaption}{}% - {\PackageWarning{frenchb.ldf}% + \@ifundefined{@makecaption}% + {\let\@makecaption\undefined}% + {\FBWarning{frenchb.ldf}% {The definition of \protect\@makecaption\space has been changed,\MessageBreak frenchb will NOT customise it;\MessageBreak reported}% @@ -1563,10 +1920,10 @@ \let\FB@makecaption\relax \let\STD@makecaption\relax } -\expandafter\addto\csname extras\CurrentOption\endcsname{% +\addto\extrasfrench{% \def\CaptionSeparator{\space\textendash\space}} -\expandafter\addto\csname noextras\CurrentOption\endcsname{% - \def\CaptionSeparator{\string:\space}} +\addto\noextrasfrench{% + \def\CaptionSeparator{\string:\space}} % \end{macrocode} % \end{macro} % @@ -1733,15 +2090,10 @@ % French which is correct for English but wrong for some languages % like Spanish. Pointed out by Juan Jos\'e Torrens.} % -% We need to save the value of the flag |\if@afterindent| +% We will need to save the value of the flag |\if@afterindent| % `AtBeginDocument' before eventually changing its value. % % \begin{macrocode} -\AtBeginDocument{\ifx\@afterindentfalse\@afterindenttrue - \let\@aifORI\@afterindenttrue - \else \let\@aifORI\@afterindentfalse - \fi -} \def\bbl@frenchindent{\let\@afterindentfalse\@afterindenttrue \@afterindenttrue} \def\bbl@nonfrenchindent{\let\@afterindentfalse\@aifORI @@ -1759,7 +2111,7 @@ % \changes{v2.0b}{2007/04/18}{Footnotes: Just do nothing % (except warning) when the bigfoot package is loaded.} % -% The |bigfoot| package deeply changes the way footnotes are +% The \file{bigfoot} package deeply changes the way footnotes are % handled. When |bigfoot| is loaded, we just warn the user that % |frenchb| will drop the customisation of footnotes. % @@ -1778,9 +2130,12 @@ % (any space typed in is removed first). This has no effect on % the layout of the footnote itself. % +% \changes{v2.4a}{2009/11/23}{\cs{PackageWarning} changed to +% \cs{FBWarning} (when bigfoot package in use).} +% % \begin{macrocode} \AtBeginDocument{\@ifpackageloaded{bigfoot}% - {\PackageWarning{frenchb.ldf}% + {\FBWarning{frenchb.ldf}% {bigfoot package in use.\MessageBreak frenchb will NOT customise footnotes;\MessageBreak reported}}% @@ -1960,13 +2315,12 @@ \csname\ifmmode M\else T\fi dots@\endcsname}% \@ifundefined{@xp}{\let\@xp\relax}{}% \@ifundefined{mdots@}{\let\Tdots@ORI\textellipsis - \let\Mdots@\mathellipsis}{}} + \let\Mdots@\mathellipsis + \let\mdots@\undefined}{}} \def\bbl@frenchdots{\let\Tdots@\FBtextellipsis} \def\bbl@nonfrenchdots{\let\Tdots@\Tdots@ORI} -\expandafter\addto\csname extras\CurrentOption\endcsname{% - \bbl@frenchdots} -\expandafter\addto\csname noextras\CurrentOption\endcsname{% - \bbl@nonfrenchdots} +\addto\extrasfrench{\bbl@frenchdots} +\addto\noextrasfrench{\bbl@nonfrenchdots} % \end{macrocode} % \end{macro} % @@ -2025,6 +2379,8 @@ % in use. When OriginalTypewriter is set to true, frenchb behaves % as in pre-2.3 versions.} % +% \changes{v2.4a}{2009/11/23}{New option SuppressWarning.} +% % We first define a collection of conditionals with their defaults % (true or false). % @@ -2044,6 +2400,7 @@ \newif\ifFBFrenchSuperscripts \FBFrenchSuperscriptstrue \newif\ifFBLowercaseSuperscripts \FBLowercaseSuperscriptstrue \newif\ifFBPartNameFull \FBPartNameFulltrue +\newif\ifFBSuppressWarning \FBSuppressWarningfalse \newif\ifFBShowOptions \FBShowOptionsfalse % \end{macrocode} % @@ -2092,8 +2449,9 @@ % |\frenchbsetup|, can overrule some of the |StandardLayout| % settings. % -% |GlobalLayoutFrench| forces the layout in French and (as far as -% possible) outside French to meet the French typographic standards. +% When French is the main language, |GlobalLayoutFrench| forces the +% layout in French and (as far as possible) outside French to meet +% the French typographic standards. % % \changes{v2.3d}{2009/03/16}{Warning added to \cs{GlobalLayoutFrench} % when French is not the main language.} @@ -2132,7 +2490,8 @@ {\PackageWarning{frenchb.ldf}% {Option `GlobalLayoutFrench' skipped: \MessageBreak French is *not* - babel's last option.\MessageBreak}}% + babel's last option.\MessageBreak}% + \FBGlobalLayoutFrenchfalse}% \fi}% \define@key{FB}{ReduceListSpacing}[true]% {\csname FBReduceListSpacing#1\endcsname}% @@ -2181,6 +2540,14 @@ {\csname FBLowercaseSuperscripts#1\endcsname} \define@key{FB}{PartNameFull}[true]% {\csname FBPartNameFull#1\endcsname}% + \define@key{FB}{SuppressWarning}[true]% + {\csname FBSuppressWarning#1\endcsname + \ifFBSuppressWarning + \renewcommand{\FBWarning}[2]{\relax}% + \else + \renewcommand{\FBWarning}[2]{% + \PackageWarning{##1}{##2}}% + \fi} \define@key{FB}{ShowOptions}[true]% {\csname FBShowOptions#1\endcsname}% % \end{macrocode} @@ -2195,18 +2562,35 @@ % The quote characters typed in depend on the input encoding, % it can be single-byte (latin1, latin9, applemac,\dots) or % multi-bytes (utf-8, utf8x). We first check whether XeTeX is used -% or not, if not the package |inputenc| has to be loaded before the -% |\begin{document}| with the proper coding option, so we check if -% |\DeclareInputText| is defined. +% or not, if not the package \file{inputenc} has to be loaded before +% the |\begin{document}| with the proper coding option, so we check +% if |\DeclareInputText| is defined. +% +% \changes{v2.4c}{2010/05/23}{In \cs{ttfamilyFB}, also cancel +% automatic spaces inside French guillemets coded as characters +% (see \cs{frenchbsetup}).} +% +% \changes{v2.5a}{2010/08/21}{Test \cs{@ifundefined} leaves the +% tested control sequence defined as \cs{relax} when TRUE. +% Changed \cs{relax} to \cs{undefined} when testing +% \cs{XeTeXrevision}, \cs{DeclareInputText}, \cs{uc@dclc}, +% \cs{DeclareUnicodeCharacter}, \cs{mule@def} in \cs{og} and +% \cs{fg}.} +% % \begin{macrocode} \define@key{FB}{og}{% - \newcommand*{\FB@@og}{\iflanguage{french}% - {\FB@og\ignorespaces}{\guillemotleft}}% - \expandafter\ifx\csname XeTeXrevision\endcsname\relax - \AtBeginDocument{% - \@ifundefined{DeclareInputText}% + \newcommand*{\FB@@og}{% + \iflanguage{french}% + {\ifFBAutoSpaceGuill\FB@og\ignorespaces + \else\guillemotleft + \fi}% + {\guillemotleft}}% + \@ifundefined{XeTeXrevision}% + {\AtBeginDocument + {\@ifundefined{DeclareInputText}% {\PackageWarning{frenchb.ldf}% {Option `og' requires package inputenc.\MessageBreak}% + \let\DeclareInputText\undefined }% {\@ifundefined{uc@dclc}% % \end{macrocode} @@ -2216,72 +2600,100 @@ % \end{macrocode} % if |\DeclareUnicodeCharacter| is undefined, utf8 is not loaded % either, we assume 8-bit character input encoding. -% Package MULEenc.sty (from CJK) defines |\mule@def| to map +% Package \file{MULEenc.sty} (from CJK) defines |\mule@def| to map % characters to control sequences. % \begin{macrocode} {\@tempcnta`#1\relax \@ifundefined{mule@def}% - {\DeclareInputText{\the\@tempcnta}{\FB@@og}}% + {\DeclareInputText{\the\@tempcnta}{\FB@@og}% + \let\mule@def\undefined}% {\mule@def{11}{{\FB@@og}}}% + \let\DeclareUnicodeCharacter\undefined }% % \end{macrocode} % utf8 loaded, use |\DeclareUnicodeCharacter|, % \begin{macrocode} {\DeclareUnicodeCharacter{00AB}{\FB@@og}}% + \let\uc@dclc\undefined }% % \end{macrocode} % utf8x loaded, use |\uc@dclc|, % \begin{macrocode} {\uc@dclc{171}{default}{\FB@@og}}% }% + }% + \let\XeTeXrevision\undefined }% % \end{macrocode} -% XeTeX in use, the following trick for defining the active quote -% character is borrowed from \file{inputenc.dtx}. +% XeTeX in use, % \begin{macrocode} - \else - \catcode`#1=\active - \bgroup - \uccode`\~`#1% - \uppercase{% - \egroup - \def~% - }{\FB@@og}% - \fi + {\ifFB@xetex@punct +% \end{macrocode} +% |XeTeXinterchartokenstate| is defined, nothing to do here, see +% subsection~\ref{sec-punct}. +% \begin{macrocode} + \else +% \end{macrocode} +% then an old XeTeX in use, the following trick for defining the +% active quote character is borrowed from \file{inputenc.dtx}. +% \begin{macrocode} + \catcode`#1=\active + \bgroup + \uccode`\~`#1% + \uppercase{% + \egroup + \def~% + }{\FB@@og}% + \fi + }% }% % \end{macrocode} % Same code for the closing quote. % \begin{macrocode} \define@key{FB}{fg}{% - \newcommand*{\FB@@fg}{\iflanguage{french}% - {\FB@fg}{\guillemotright}}% - \expandafter\ifx\csname XeTeXrevision\endcsname\relax - \AtBeginDocument{% - \@ifundefined{DeclareInputText}% + \newcommand*{\FB@@fg}{% + \iflanguage{french}% + {\ifFBAutoSpaceGuill\FB@fg + \else\guillemotright + \fi}% + {\guillemotright}}% + \@ifundefined{XeTeXrevision}% + {\AtBeginDocument + {\@ifundefined{DeclareInputText}% {\PackageWarning{frenchb.ldf}% {Option `fg' requires package inputenc.\MessageBreak}% + \let\DeclareInputText\undefined }% {\@ifundefined{uc@dclc}% {\@ifundefined{DeclareUnicodeCharacter}% {\@tempcnta`#1\relax \@ifundefined{mule@def}% - {\DeclareInputText{\the\@tempcnta}{{\FB@@fg}}}% + {\DeclareInputText{\the\@tempcnta}{{\FB@@fg}}% + \let\mule@def\undefined + }% {\mule@def{27}{{\FB@@fg}}}% + \let\DeclareUnicodeCharacter\undefined + }% + {\DeclareUnicodeCharacter{00BB}{{\FB@@fg}}% }% - {\DeclareUnicodeCharacter{00BB}{{\FB@@fg}}}% + \let\uc@dclc\undefined }% {\uc@dclc{187}{default}{{\FB@@fg}}}% }% + }% + \let\XeTeXrevision\undefined + }% + {\ifFB@xetex@punct + \else + \catcode`#1=\active + \bgroup + \uccode`\~`#1% + \uppercase{% + \egroup + \def~% + }{{\FB@@fg}}% + \fi }% - \else - \catcode`#1=\active - \bgroup - \uccode`\~`#1% - \uppercase{% - \egroup - \def~% - }{{\FB@@fg}}% - \fi }% } % \end{macrocode} @@ -2326,17 +2738,27 @@ % |CompactItemize| suppresses the vertical spacing between list % items in French (done by changing |\itemize| to |\itemizeFB|). % When |GlobalLayoutFrench| is true the same is done outside French. +% +% \changes{v2.4b}{2010/04/30}{Set flag CompactItemize=false when the +% enumitem package is loaded (ensures compatibility).} +% % \begin{macrocode} + \@ifpackageloaded{enumitem}{% + \FBCompactItemizefalse + \FBWarning{frenchb.ldf}% + {Setting CompactItemize=false for compatibility\MessageBreak + with enumitem package,}}% + {}% \ifFBCompactItemize - \addto\extrasfrench{\let\itemize\itemizeFB + \addto\extrasfrench{\let\itemize\itemizeFB \let\enditemize\enditemizeFB}% - \addto\noextrasfrench{\ifFBGlobalLayoutFrench + \addto\noextrasfrench{\ifFBGlobalLayoutFrench \let\itemize\itemizeFB \let\enditemize\enditemizeFB - \else + \else \let\itemize\itemizeORI \let\enditemize\enditemizeORI - \fi}% + \fi}% \else \addto\extrasfrench{\let\itemize\itemizeORI \let\enditemize\enditemizeORI}% @@ -2365,16 +2787,18 @@ % % |IndentFirst| forces the first paragraphs of sections to be % indented just like the other ones in French. -% When |GlobalLayoutFrench| is true (the default), the same is -% done outside French except for languages that force a different -% setting. +% When |GlobalLayoutFrench| is true, the same is done outside French +% except for languages that force a different setting. +% |\bbl@nonfrenchindent| has been designed to be smart with other +% languages (like Spanish) who also indent every first paragraphs of +% sections (see section~\ref{sec-indent}). % \begin{macrocode} \ifFBIndentFirst \addto\extrasfrench{\bbl@frenchindent}% \addto\noextrasfrench{\ifFBGlobalLayoutFrench - \bbl@frenchindent + \bbl@frenchindent \else - \bbl@nonfrenchindent + \bbl@nonfrenchindent \fi}% \else \addto\extrasfrench{\bbl@nonfrenchindent}% @@ -2415,15 +2839,15 @@ % |ThinColonSpace| changes the normal unbreakable space typeset in % French before `:' to a thin space. % \begin{macrocode} - \ifFBThinColonSpace\renewcommand*{\Fcolonspace}{\thinspace}\fi + \ifFBThinColonSpace\renewcommand*{\Fcolonspace}{\Fthinspace}\fi % \end{macrocode} % % When |true|, |ThinSpaceInFrenchNumbers| redefines |numprint.sty|'s % command |\npstylefrench| to set |\npthousandsep| to |\,| % (thinspace) instead of |~| (default) . This option has no effect -% if package |numprint.sty| is not loaded with `|autolanguage|'. -% As old versions of |numprint.sty| did not define |\npstylefrench|, -% we have to provide this command. +% if package \file{numprint.sty} is not loaded with `|autolanguage|'. +% As old versions of \file{numprint.sty} did not define +% |\npstylefrench|, we have to provide this command. % \begin{macrocode} \@ifpackageloaded{numprint}% {\ifnprt@autolanguage @@ -2492,6 +2916,7 @@ StandardLayout=true [false]\MessageBreak GlobalLayoutFrench=false [true]\MessageBreak StandardLists=true [false]\MessageBreak + IndentFirst=false [true]\MessageBreak ReduceListSpacing=false [true]\MessageBreak CompactItemize=false [true]\MessageBreak StandardItemLabels=true [false]\MessageBreak @@ -2505,7 +2930,6 @@ \protect\ding{43},... [\textendash]\MessageBreak ItemLabeliv=\textemdash, \textbullet, \protect\ding{43},... [\textendash]\MessageBreak - IndentFirst=false [true]\MessageBreak FrenchFootnotes=false [true]\MessageBreak AutoSpaceFootnotes=false [true]\MessageBreak AutoSpacePunctuation=false [true]\MessageBreak @@ -2515,6 +2939,7 @@ FrenchSuperscripts=false [true]\MessageBreak LowercaseSuperscripts=false [true]\MessageBreak PartNameFull=false [true]\MessageBreak + SuppressWarning=true [false]\MessageBreak og= <left quote character>, fg= <right quote character> \MessageBreak ********************************************* @@ -2533,15 +2958,25 @@ % % \changes{v2.1b}{2008/04/07}{Disable some commands in bookmarks.} % -% At |\begin{document}| we save again the definitions of the `list' -% and `itemize' environments and the values of labelitems so that -% all changes made in the preamble are taken into account in -% languages other than French and in French with the StandardLayout -% option. We also have to provide an |\xspace| command in case the -% |xspace.sty| package is not loaded. +% \changes{v2.5a}{2010/08/21}{Test \cs{@ifundefined} leaves the +% tested control sequence defined as \cs{relax} when TRUE. +% Changed \cs{relax} to \cs{undefined} when testing +% \cs{pdfstringdefDisableCommands} AtBeginDocument.} +% +% At |\begin{document}| we save again the value of |\if@afterindent| +% and definitions of the `list' and `itemize' environments and the +% values of labelitems so that all changes made in the preamble are +% taken into account in languages other than French and in French +% with the StandardLayout option. +% We also have to provide an |\xspace| command in case the +% \file{xspace.sty} package is not loaded. % % \begin{macrocode} \AtBeginDocument{% + \ifx\@afterindentfalse\@afterindenttrue + \let\@aifORI\@afterindenttrue + \else \let\@aifORI\@afterindentfalse + \fi \let\listORI\list \let\endlistORI\endlist \let\itemizeORI\itemize @@ -2573,16 +3008,38 @@ \def\fg{\space\guillemotright}% \let\bsc\textsc \let\degres\degre - }}% + }% + \let\pdfstringdefDisableCommands\undefined}% % \end{macrocode} +% % It is time to process the options set with |\frenchboptions{}|. -% Then execute either |\extrasfrench| and |\captionsfrench| or -% |\noextrasfrench| according to the current language at the -% |\begin{document}| (these three commands are updated by -% |\FBprocess@options|). +% Then we need to execute either |\extrasfrench| and +% |\captionsfrench| or |\noextrasfrench| according to the current +% language at the |\begin{document}| (these three commands have been +% updated by |\FBprocess@options|). \emph{But}, when French is the +% main language, |\extrasfrench| is executed \emph{again} now +% (French has been switched on `AtBeginDocument' some time before). +% This is harmless, except for |\bbl@frenchspacing| which will +% redefine |\bbl@nonfrenchspacing| to |\relax|, this will be +% wrong if the user switches to English. +% When French is \emph{not} the main language, |\noextrasfrench| +% executes |\bbl@nonfrenchspacing| (=|\nonfrenchspacing|), thus +% eventually overwriting a |\frenchspacing| command issued by the +% main language (German, Spanish, etc.). +% So we have to define |\bbl@nonfrenchspacing| as |\relax| here +% and restore it's meaning afterwards. +% +% \changes{v2.5a}{2010/08/15}{Define \cs{bbl@nonfrenchspacing} locally +% as \cs{relax}, otherwise the \cs{bbl@frenchspacing} command +% included in germanb.ldf is overwritten here by +% \cs{noextrasfrench}. Bug pointed out by Ulrike Fischer.} +% % \begin{macrocode} \FBprocess@options + \let\bbl@nonfrenchspacingORI\bbl@nonfrenchspacing + \let\bbl@nonfrenchspacing\relax \iflanguage{french}{\extrasfrench\captionsfrench}{\noextrasfrench}% + \let\bbl@nonfrenchspacing\bbl@nonfrenchspacingORI % \end{macrocode} % Some warnings are issued when output font encodings are not % properly set. With XeLaTeX, \file{fontspec.sty} and @@ -2591,24 +3048,25 @@ % Mind that |\encodingdefault| is defined as `long', defining % |\FBOTone| with |\newcommand*| would fail! % \begin{macrocode} - \expandafter\ifx\csname XeTeXrevision\endcsname\relax - \begingroup \newcommand{\FBOTone}{OT1}% + \@ifundefined{XeTeXrevision}% + {\begingroup \newcommand{\FBOTone}{OT1}% \ifx\encodingdefault\FBOTone \PackageWarning{frenchb.ldf}% {OT1 encoding should not be used for French. \MessageBreak Add \protect\usepackage[T1]{fontenc} to the - preamble\MessageBreak of your document,} + preamble\MessageBreak of your document,}% \fi - \endgroup - \else - \@ifundefined{DeclareUTFcharacter}% - {\PackageWarning{frenchb.ldf}% - {Add \protect\usepackage{fontspec} *and*\MessageBreak - \protect\usepackage{xunicode} to the preamble\MessageBreak - of your document,}}% - {}% - \fi + \endgroup + \let\XeTeXrevision\undefined + }% + {\@ifundefined{DeclareUTFcharacter}% + {\PackageWarning{frenchb.ldf}% + {Add \protect\usepackage{xltxtra} to the\MessageBreak + preamble of your document,}% + \let\DeclareUTFcharacter\undefined}% + {}% + }% } % \end{macrocode} % |