Babel 多种语言和章节标签

Babel 多种语言和章节标签

我正在写一篇用英语写的博士论文,但应该包含一章法语。我尝试添加多种语言支持,使用:

\usepackage[french, english]{babel}

但是如果我这样做,在第一章之后的第一个标签处我会出现奇怪的错误:

\chapter{Test}
\label{chap:test}
This is a test chapter.

如果我删除它,\label{chap:test}它就可以正常工作。有人知道问题可能出在哪里以及如何解决它吗?

第一个错误是:

[3] (./Tesi.aux (./Chapters/FrechR.aux
! Missing \endcsname inserted.
<to be read again> 
               \mathrel 
l.8 ...narycolon }test}{{1}{2}{Test}{chapter.1}{}}

虽然我的序言是

% Declare that this style file requires at least LaTeX version 2e.
\NeedsTeXFormat{LaTeX2e}

%\usepackage[a-1b]{pdfx} %serve create a pdf-a

% Provide the name of your page, the date it was last updated, and a comment about what it's used for
\ProvidesPackage{Preamble}[2019/03/29 Stefano thesis preamble]

\usepackage[french, english]{babel} %linguistic support (stefano)
% General Packages
\usepackage[utf8]{inputenc} % For input encoding and stressed characters
\usepackage[babel]{csquotes} % for right csquotes detection
\usepackage[includeheadfoot,margin=25mm,bindingoffset=10mm]{geometry} % For correct positionning on a A4 paper sheet
\usepackage{graphicx} % For \includegraphics[scale=•]{•}
\usepackage{url} %for correct visualization of urls

% Font Packages
% \usepackage{lmodern} % For Latin Modern !!! Way too thin !!!
% \usepackage{textcomp} %companion fonts, cross and tics mainly (stefano)
\usepackage{libertine} % For Linux Libertine
\usepackage{amsthm} %for writing theorems has to be before newtxmath
\usepackage[libertine]{newtxmath} % For Linux Libertine matching math font
%\usepackage{libertinust1math} % For better Linux Libertine maths | needs to be installed though but should be pretty nice
\usepackage{commath}

% Other fonts I tried
%\usepackage{fouriernc} % URW Schoolbook L (Val's maths, too crazy)
%\usepackage{tgschola} % Enhanced URW Schoolbook L (replaces text glyphs)
%\usepackage{stix} % For Stix font along with its maths (DID NOT WORK)
%\usepackage{newtxtext,newtxmath} % For TX fonts along with maths (newtxtext DID NOT WORK)

\usepackage[T1]{fontenc} % For nice hyphenation of words with accented characters mostly

% \usepackage{listings} %for listings of codes
% \lstloadlanguages{C, bash}
% \lstnewenvironment{lstC}[1][]
% {\lstset{language=C,numbers=left,breaklines=true,
%     basicstyle=\small\ttfamily,#1}}{}
% \lstnewenvironment{lstbash}[1][]
% {\lstset{language=bash,numbers=left,breaklines=true,
%     basicstyle=\small\ttfamily,#1}}{}

% \makeatletter
% \lst@Key{matchrangestart}{f}{\lstKV@SetIf{#1}\lst@ifmatchrangestart}
% \def\lst@SkipToFirst{%
%   \lst@ifmatchrangestart\c@lstnumber=\numexpr-1+\lst@firstline\fi
%   \ifnum \lst@lineno<\lst@firstline
%   \def\lst@next{\lst@BeginDropInput\lst@Pmode
%     \lst@Let{13}\lst@MSkipToFirst
%     \lst@Let{10}\lst@MSkipToFirst}%
%   \expandafter\lst@next
%   \else
%   \expandafter\lst@BOLGobble
%   \fi}
% \makeatother

% Maths Packages
\usepackage{amsmath}
% \usepackage{amsfonts} loaded by the following
\usepackage{amssymb} % For more maths symbols. It loads amsfonts package.
\renewcommand{\epsilon}{\varepsilon} %normally used in europe
\renewcommand{\theta}{\vartheta} %normally used in europe
\renewcommand{\rho}{\varrho} %normally used in europe
\renewcommand{\phi}{\varphi} %normally used in europe


\newcommand\bmmax{2} % Just to help bm dealing with over 16 maths alphabets

\usepackage{bm} % For bold maths symbols
\usepackage{dsfont} % For a nice double-sided capital 1 with \mathds{1}
\usepackage{mathrsfs} % For nice script like capital letters with \mathsf{L}

% Headers, footers configuration
\usepackage{fancyhdr} % For nice headers
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\fontsize{10}{12} \selectfont \slshape \leftmark}
\fancyhead[LE]{\fontsize{10}{12} \selectfont \slshape \rightmark}
\fancyfoot[C]{\thepage}
\usepackage{emptypage} % To clear empty pages with \thispagestyle{empty}

% Links
%\usepackage[pagebackref=true, colorlinks=false, pdfborder={0 0 0},
\usepackage[pagebackref=false, colorlinks=false, pdfborder={0 0 0},
pdftex,bookmarks=true,bookmarksdepth=3,pdfencoding=auto, psdextra]{hyperref} % For clickable links through
                                                  % the doc and backreferencing
                                                  % in the biblio
\pdfstringdefDisableCommands{\def\gd{antibunching}}
\hypersetup{colorlinks=true, citecolor=[rgb]{0.47,0.04,0.76},
  linkcolor=[rgb]{0.00,0.45,0.81},bookmarksnumbered} % Setting some nice colors

% %Tuning the backreferencing
% \renewcommand*{\backref}[1]{}
% \renewcommand*{\backrefalt}[4]{({\footnotesize%
%     \ifcase #1 Not cited.%
%     \or Cited on page~#2.%
%     \else Cited on pages #2.%
%     \fi%
%   })}

% Miscellanous Packages
\usepackage{bookmark} % For advanced PDF bookmarks management
\usepackage{caption}
%\usepackage{subcaption} % For side-by-side figures which I didn't use
\usepackage[caption=false]{subfig} % For side-by-side figures, caption=false
                                % tell to not affect the caption. To be
                                % evaluated.
\usepackage{cprotect} % for protected captions
%\DeclareCaptionFormat{myformat}{#1#2#3\hspace{0.25\linewidth}\rule{0.5\linewidth}{0.3pt}}
%\captionsetup[figure]{format=myformat} %%add a line after each figure caption


% \usepackage{wrapfig} used to wrap text around figures
% \usepackage{rotating} % girare le figure

\usepackage[exponent-product=\cdot]{siunitx} % For nice scientific notation,
%nicely displayed units,
                     % check the doc
\usepackage{booktabs} % For really nice tabs
%\usepackage{todonotes} % For to-do list - Did not use it
%\usepackage{multicol} % For multicolumn environment - Did not use it
\usepackage[tight]{minitoc} % For tables of content by chapters / recommend the
                            % tight option
\usepackage[toc,page]{appendix} % For appendices management
\usepackage[above,below]{placeins} % To avoid floats (figures) passing anythin
%with \FloatBarrier
\usepackage{floatrow}

%%to add boxes around figures

%end to add boxes around figures

% Configure the depth of sections, table of content and minitoc
\setcounter{secnumdepth}{2} % I like to have numbering down to subsubections
\setcounter{tocdepth}{2} % You want to stop the main toc at subsections, that's more than enough
\setcounter{minitocdepth}{3} % You want them all in minitocs


% Paths for figures and logos
\graphicspath{{Immagini/}}

%for quantum states
%\usepackage{braket}

% Some life saving macro to speed up writing and give you agility

% \def\({\left(} % super useful
% \def\){\right)} % super useful
% \def\[{\left[}
% \def\]{\right]}
% \def\bdiv{\;\big/\;} % Oh yeah ! Big div baby ! Big div !
% \def\+{\dagger} % Cause ^\+ is much better than ^{\dagger}
% \def\8{\infty}


%------------ other random commands I define ---------------%


%\newcommand{\ba}[1]{\begin{array}{#1}}
%\newcommand{\ea}{\end{array}}

%\newcommand{\lr}[1]{\left( #1 \right)}
%\newcommand{\ddd}{\mathrm{d}}

% Here's the Greek ! Always business !
% \def\a{\alpha}
% \def\b{\beta}
% \def\g{\gamma}
% \def\G{\Gamma}
% \def\d{\delta}
% \def\D{\Delta}
% \def\eps{\varepsilon}
% \def\e0{\epsilon_0}
% \def\ka{\kappa}
% \def\la{\lambda}
% \def\m{\mu}
% \def\n{\nu}
% \def\p{\psi}
% \def\P{\Psi}
% \def\po{\mathcal{P}} % For optical powers
% \def\s{\sigma}
% \def\t{\tau}
% \def\tt{\theta}
% \def\vtt{\theta_{pol}} % I initialy used \varepsilon ...  whatever
% \def\v{\nu}
% \def\w{\omega}
% \def\W{\Omega}
% \def\l"{\lq\lq} % In English, they look like that, period
% \def\r"{\rq\rq}
% \def\E{\hat{\textbf{E}}} % For the electric field
% \def\fE{\mathscr{E}^{(1)}} % For the field constant
% \def\rp{\bm{r}} % For the position vector
% \def\k{\textbf{k}} % Momentum vector

% %quadrature vectors
% \def\q{\textbf{q}}
% \def\p{\textbf{p}}

% \def\pd{\partial} % For partial derivation
% \def\ldots{...} % I redefined them, originals are too spaced
% \def\twith{\quad \text{with} \quad} % I like to put that in equations
% \def\twhere{\quad \text{where} \quad} % Same
% \def\tand{\quad \text{and} \quad} % same


% % Functions
% \DeclareMathOperator{\Tr}{Tr}
% \DeclareMathOperator{\ch}{ch}
% \DeclareMathOperator{\sh}{sh}
% \DeclareMathOperator{\tnh}{th}
% \DeclareMathOperator{\sinc}{sinc}
%\let\Re\undefined %cambio il comando per la parte reale, che non mi piace
%\DeclareMathOperator{\Re}{Re}
\newcommand{\NA}{\mathrm{NA}}
\newcommand{\defeq}{\stackrel{\text{\tiny def}}{=}}
% \newcommand{\ud}{\,\mathrm{d}} % For upright d in the integrals
% \newcommand{\matrixel}[3]{\ensuremath{\left\langle #1 \vphantom{#2#3} \right| #2 \left| #3 \vphantom{#1#2} \right\rangle}} % For Dirac notation matrix element
% \newcommand{\analE}[1]{\E^{(#1)}} % It's the analytic field, not what you're thinking !

% For Chapter Quotes
\newenvironment{chapquote}[2][2em]
  {\setlength{\@tempdima}{#1}%
   \def\chapquote@author{#2}%
   \parshape 1 \@tempdima \dimexpr\textwidth-2\@tempdima\relax%
   \itshape}
  {\par\normalfont\hfill--\ \chapquote@author\hspace*{\@tempdima}\par\bigskip}

% For the biblio's name
\renewcommand{\bibname}{References}

%%---- quantum circuit package ------%
%\input{Qcircuit}
%%--- avarage ---%
\newcommand{\avr}[1]{\left<#1\right>}

%---- basic Dirac notation ----%
\newcommand{\Bra}[2][]{\left<#2\right|_{#1}}
\newcommand{\Ket}[2][]{\left|#2\right>_{\hspace{-0.1em}#1}}

% ---- compound Dirac notation ----%
%\newcommand{\ketbra}[3][]{\mathinner{\lvert#2\rangle\langle #3\rvert}_{#1}}
\newcommand{\Ketbra}[3][]{\left|#2\middle> _{#1} \middle<#3\right|}
\newcommand{\proj}[2][]{\ketbra[#1]{#2}{#2}}
\newcommand{\Proj}[2][]{\Ketbra[#1]{#2}{#2}}


\newcommand{\Bracket}[4][]{_{#1}\mathinner{\langle #2 \lvert #3 \rangle}_{#4}}

%%------------ other random commands I define ---------------%

%\newcommand{\be}{\begin{equation}}
%\newcommand{\ee}{\end{equation}}


% \newcommand\restr[2]{{% we make the whole thing an ordinary symbol
%   \left.\kern-\nulldelimiterspace % automatically resize the bar with \right
%   #1 % the function
%   \vphantom{\big|} % pretend it's a little taller at normal size
%   \right|_{#2} % this is the delimiter
%   }}

%\newcommand{\bs}[1]{\boldsymbol{#1}}


% \renewcommand{\Re}{\operatorname{Re}}
% \renewcommand{\Im}{\operatorname{Im}}

%%---- commands from stefano ----%%


% % useful when using listings package
% \newcommand{\inclC}[3][]{
%   \lstinputlisting[linerange={#2}, breaklines=true, matchrangestart=t,
%   numbers=left, language=C, basicstyle=\small\ttfamily , #1]{#3} }
% \newcommand{\inclMat}[3][]{
%   \lstinputlisting[linerange={#2}, breaklines=true, matchrangestart=t,
%   numbers=left, language=Matlab, basicstyle=\small\ttfamily , #1]{#3} }

\newcommand*{\fig}[1]{figure~\ref{fig:#1}}
\newcommand*{\eng}[1]{\textit{#1}}

%\newcommand*{\pd}[2]{\dfrac{\partial#1}{\partial #2}}
\newcommand*{\ppd}[2]{\dfrac{\partial^2 #1}{\partial #2^2}}
\newcommand{\den}{1+\dfrac{R_5}{R_3}+\dfrac{R_5}{R_4}}

%\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\tonda}[1]{\left(#1\right)}
\newcommand{\of}[1]{\left(#1\right)}
\newcommand{\quadra}[1]{\left[#1\right]}
\newcommand{\graffa}[1]{\left\{#1\right\}}
\newcommand{\D}{\Delta}
\newcommand{\ket}[1]{\left|#1\right>}
\newcommand{\bra}[1]{\left<#1\right|}
\newcommand{\braket}[3]{\left<#1\middle|#2\middle|#3\right>}
\newcommand{\mean}[1]{\left<#1\right>}

\newcommand{\Erel}[1]{ \\
  tonda{\dfrac{\Delta #1}{#1}}^2}
\newcommand{\down}[1]{\frac{1}{#1}}
\newcommand{\ddown}[1]{\dfrac{1}{#1}}

\DeclareMathOperator{\Variance}{\widehat{Var}}
\newcommand{\Var}[1]{\Variance\of{#1}}
\DeclareMathOperator{\Tr}{Tr}


\newcommand{\Sch}{Schr\"odinger}

% \newcommand{\aaa}[1]{\hat{a}_{#1}}
% \newcommand{\aad}[1]{\hat{a}_{#1}^{\dag}}
% \newcommand{\bbb}[1]{\hat{b}_{#1}}
% \newcommand{\bbd}[1]{\hat{b}_{#1}^{\dag}}
% \newcommand{\kort}{k_{\perp}}
% \newcommand{\kortv}{\vec{k}_{\perp}}
\newcommand{\Matlab}{Matlab}
% \newcommand{\slf}{\mathscr{E}}
% \newcommand{\slft}{\tilde{\mathscr{E}}}
% \newcommand{\Def}{\overset{\mathit{def}}{=}}
\newcommand{\Rasp}{Raspberry-Pi}
\newcommand{\Raspbian}{``Raspbian''}
% \newcommand{\usbtmc}{\textsc{usbtmc}}
\newcommand{\Python}{\textit{Python}}
\newcommand{\Bash}{\textit{Bash}}
\newcommand{\gd}{$\textrm{g}^{(2)}$}
\newcommand{\gdt}{$\textrm{g}^{(2)}\of{\tau}$}
\newcommand{\gdz}{$\textrm{g}^{(2)}\of{0}$}

\newcommand{\credit}[1]{\textit{credits: #1}.}
\newcommand{\ccredit}[1]{\textit{(credits: \textcite{#1})}.}
\newcommand{\ccreditnp}[1]{\textit{(credits: \textcite{#1})}}
\newcommand{\IEW}{Ion-exchange glass waveguide}
\newcommand{\iEW}{ion-exchange glass waveguide}
\newcommand{\PEW}{polymerization by evanescent waves}
\def\CC{{C\nolinebreak[4]\hspace{-.05em}\raisebox{.3ex}{\footnotesize\bf ++}}}
\def\CCT{{C\hspace{-.05em}\raisebox{.35ex}{\bf \footnotesize ++}}}

\newenvironment{changemargin}[2]{%
  \begin{list}{}{%
      \setlength{\topsep}{0pt}%
      \setlength{\leftmargin}{#1}%
      \setlength{\rightmargin}{#2}%
      \setlength{\listparindent}{\parindent}%
      \setlength{\itemindent}{\parindent}%
      \setlength{\parsep}{\parskip}%
    }%
  \item[]}{\end{list}}

\usepackage[onehalfspacing]{setspace}
%\linespread{1.2} change interline spacing

\let\oldvec\vec %keep the vector with arrow
%%--- end ---%%

\usepackage{changepage}
\usepackage{empheq}

% for PSL cover
%\usepackage{fontspec}
%\usepackage{lmodern}
%\usepackage{lipsum}
\usepackage{psl-cover}
%\usepackage[]{frontespizio} the frontespizio used for thesis in Florence


%bibliography informations
\usepackage[backend=biber,style=numeric,sorting=none, url=false]{biblatex} %biblatex use
\addbibresource{bibliografia.bib}

%Penality to avoid equations to break between lines:
\binoppenalty=10000
\relpenalty=10000

%package for chemical formulas
\usepackage{chemformula}

%for color line in table
%\usepackage[table]{xcolor}

%for colored box at the end of chapters
%\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\newenvironment{chrecap}{
    \begin{tcolorbox}[enhanced,attach boxed title to top
        center={yshift=-3mm,yshifttext=-1mm},
        colback=blue!5!white,colframe=blue!75!black,colbacktitle=red!80!black,
        title={Conclusions},fonttitle=\bfseries,
        boxed title style={size=small,colframe=red!50!black} ]
    }
    {
    \end{tcolorbox}
    }


% Finally, we use \endinput to indicate that LaTeX can stop reading this file. LaTeX will ignore anything after this line.
\endinput

答案1

避免法语中四个活动字符(即 : ; ! ?)问题的另一种方法是切换到现代 TeX 引擎 LuaTeX(或 XeTeX)。使用这些引擎,不需要活动字符,高标点符号前所需的空格以另一种更安全的方式添加。

切换很容易:参见 fihttp://daniel.flipo.free.fr/doc/luatex/pdf2lua.pdf

答案2

问题出在commath包中,可能是错误。将其从序言中删除解决了问题。在使用语言时,是否可以避免:在标签中使用french,因为它们可能会产生问题。

相关内容