[Tex/LaTex] Fontspec with bibtex with accents give me a bug : “Missing \endcsname inserted. \char”

accentsbabelbiblatexfontspecscrbook

i try to get out of a 3 days trouble, hope for your help !

I just want to find my bibliography in my font without bug…

I'm using \documentclass{scrbook}, & {Adobe Garamond Pro} font with \fontspec for writing my thesis, but I have a problem with my bibtex bibliography : two ways.

  1. when I compile xelatex-biblatex-xelatex, \printbibliography is done, it's printed in a font I don't know (may be a original font of Latex),
  2. and after if I try to force my {Adobe Garamond Pro} font with \renewcommand*{\bibfont}{\fontspec{Adobe Garamond Pro}}
  3. or with \newfontfamily\normalfont{Adobe Garamond Pro},

when I compile xelatex-biblatex-xelatex, come a lot of "Missing \endcsname inserted. \char"

Of course, I use accents in my Biblio.bib because my literacy is in french & I work with the Papers2 bibliography application…

I don't know if I have to search in any direction :

  • why \bibfont \natbibor \bibtex didn't accept accents ?
  • may \frenchbof \babel have a solution with a \frenchbsetup? I don't think
  • or in \fontenc or \fontspecdirections

Please help.
Thanks

That's my config :

\documentclass[12pt]{scrbook}
    \addtokomafont{disposition}{\vfamily}
    \addtokomafont{pageheadfoot}{\vfamily}      
    \addtokomafont{pagenumber}{\vfamily\small}  
    \addtokomafont{footnote}{\vfamily}              
\usepackage{fontspec}                           
\usepackage[T1]{fontenc}                        
\usepackage{xltxtra}                            
    \newfontfamily\vfamily{Adobe Garamond Pro}
%   \newfontfamily\normalfont{Adobe Garamond Pro} % or point 3
\usepackage{xunicode}                           
\usepackage[applemac]{inputenc}             
\usepackage{lmodern, textcomp}          
\usepackage[english,frenchb]{babel}             
    \frenchbsetup{FrenchFootnotes=false}    
\usepackage[babel,french=guillemets*]{csquotes}
    \MakeOuterQuote{"}                          
    \frenchspacing                                  
    \usepackage[automark]{scrpage2}
\usepackage{lipsum}                         
\usepackage[natbib=true,style=authortitle-icomp,doi=false]{biblatex}
    \addbibresource{Biblio.bib}
    \AtBeginBibliography{\def\UrlFont{\\\scriptsize}}                       
%\renewcommand*{\bibfont}{\normalfont}  % point 2    

\begin{document}
\fontspec{Adobe Garamond Pro}
\lipsum[1]\footcite[13]{Deotte:1993ve}\lipsum[2]\footcite[13]{Ricoeur:2000ga}
\printbibliography % point 1
\end{document}

And my Biblio.bib

@article{Ricoeur:2000ga,
author = {Ric{\oe}ur, Paul}, % I know that the problem is here :s
title = {{L'{\'e}criture de l'histoire et la repr{\'e}sentation du pass{\'e}}},
journal = {ahess},
year = {2000},
volume = {55},
number = {4},
pages = {731--747},
doi = {10.3406/ahess.2000.279877},
rating = {0},
date-added = {2014-01-29T09:45:37GMT},
date-modified = {2014-01-29T09:46:30GMT},
url = {http://www.persee.fr/web/revues/home/prescript/article/ahess_0395-       2649_2000_num_55_4_279877},
uri = {\url{papers2://publication/doi/10.3406/ahess.2000.279877}}
}

@book{Deotte:1993ve,
author = {D{\'e}otte, Jean-Louis},
title = {{Le mus{\'e}e, l'origine de l'esth{\'e}tique}},
publisher = {L'Harmattan},
year = {1993},
address = {Paris},
language = {fran{\c c}ais},
rating = {0},
date-added = {2013-07-08T22:13:04GMT},
date-modified = {2014-01-29T10:03:20GMT},
uri = {\url{papers2://publication/uuid/4A77F971-C505-4B1A-AB84-6647B00EAAF0}}
}

Best Answer

You're misusing XeLaTeX. Your files must be saved as UTF-8 (well, it's possible to have other encodings, but it's definitely not recommended).

The inputenc package mustn't be loaded; fontenc may, but in your case it's completely useless. Don't load lmodern, which is not tailored for XeLaTeX. Also textcomp is generally useless with XeLaTeX. Finally, xunicode shouldn't be called for (but it's not a problem, because it's already loaded by fontspec). Use xltxtra only if you need its features.

Moreover, the main font should be declared with \setmainfont. Defining \normalfont as a font family is wrong. After using \setmainfont you can use \normalfont for returning to a "clean state", as I did in the \addtokomafont. You can use\rmfamily`, instead, if you just don't want the default sans serif font that's used by default in section titles, but you want to keep boldface.

Avoid direct calls of \fontspec.

Here's a polished version of your document. The filecontents* environment and \addbibresource{\jobname.bib} are just for making the example selfcontained. Use \addbibresource{Biblio.bib} in your document. Finally, since I don't have the font you want, I changed it, but you find the good call commented out.

\begin{filecontents*}{\jobname.bib}
@article{Ricoeur:2000ga,
author = {Ric{\oe}ur, Paul}, % I know that the problem is here :s
title = {{L'{\'e}criture de l'histoire et la repr{\'e}sentation du pass{\'e}}},
journal = {ahess},
year = {2000},
volume = {55},
number = {4},
pages = {731--747},
doi = {10.3406/ahess.2000.279877},
rating = {0},
date-added = {2014-01-29T09:45:37GMT},
date-modified = {2014-01-29T09:46:30GMT},
url = {http://www.persee.fr/web/revues/home/prescript/article/ahess_0395-2649_2000_num_55_4_279877},
uri = {\url{papers2://publication/doi/10.3406/ahess.2000.279877}}
}

@book{Deotte:1993ve,
author = {D{\'e}otte, Jean-Louis},
title = {{Le mus{\'e}e, l'origine de l'esth{\'e}tique}},
publisher = {L'Harmattan},
year = {1993},
address = {Paris},
language = {fran{\c c}ais},
rating = {0},
date-added = {2013-07-08T22:13:04GMT},
date-modified = {2014-01-29T10:03:20GMT},
uri = {\url{papers2://publication/uuid/4A77F971-C505-4B1A-AB84-6647B00EAAF0}}
}
\end{filecontents*}

\documentclass[12pt]{scrbook}

\usepackage[english,frenchb]{babel}
\usepackage{fontspec}

\usepackage[automark]{scrpage2}
\usepackage[babel,french=guillemets*]{csquotes}
\usepackage[natbib=true,style=authortitle-icomp,doi=false]{biblatex}

\usepackage{lipsum}                         

\frenchbsetup{FrenchFootnotes=false}
\MakeOuterQuote{"}
%\frenchspacing % already done by French

%\setmainfont{Adobe Garamond Pro} % I don't have it
\setmainfont{Linux Libertine O}

\addtokomafont{disposition}{\normalfont}
\addtokomafont{pageheadfoot}{\normalfont}
\addtokomafont{pagenumber}{\normalfont\small}
\addtokomafont{footnote}{\normalfont}

\addbibresource{\jobname.bib}
\AtBeginBibliography{\def\UrlFont{\\\scriptsize}}                       

\begin{document}

\lipsum[1]\footcite[13]{Deotte:1993ve}\lipsum[2]\footcite[13]{Ricoeur:2000ga}

\printbibliography % point 1

\end{document}

Here's a picture of the bibliography that I got after running Biber.

enter image description here


With TeXShop it's easy to change the encoding of a file: don't touch the general preferences, but simply add at the beginning of the file the line

% !TEX encoding = UTF-8 Unicode

Close and reopen the file. It should work correctly.