7

I am trying to use a bibliography for a my latex report. I am using a .bib file named bibli with articles written in french (so the titles have accents like é or ô). At the beginning of my .tex file I have

\usepackage[utf8]{inputenc}  
\usepackage[T1]{fontenc}

in order to write accents without using

{'\{e}} 

for é in my file. It works just fine for the text in my .tex file. However in my bibliography (bibli.bib) it doesn't work because it returns "?" instead of any accented letters. Is there a way to corect this without using {'{e}} for each bibliography reference ? I already checked the preferences of my editor (TeXMaker) and the encoding is already UTF-8

Thanks in advance

  • 2
    The simplest way is to compile your bibliography with biber/biblatex. Biber understands natively utf8, bibtex doesn't. – Bernard May 8 '15 at 13:24
7

You should use the modern replacement for bibtex: biblatex with its biber backend. It is fully unicode capable.

If you want to take it one more step further, you might also want to switch to a native unicode-enginge: xelatex or lualatex. You just have to change a few packages in the preamble. The combination of \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc} has to be replaced by \usepackage{fontspec}.

This package takes care of font and input encoding. All you need are utf8 encoded source files. You can also use every truetype or opentype font.

For language support polyglossia should be preferred to babel.

Here is an example that works both with lualatex and xelatex:

\documentclass{scrartcl}

\begin{filecontents}{references.bib}
   @ARTICLE{test,
     TITLE = {à è ê á é},
     JOURNAL = {des accents},
     YEAR = {2015},
   }
\end{filecontents}

\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}

\usepackage[backend=biber]{biblatex}
\addbibresource{build/references.bib}

\begin{document}
  \cite{test}
  \printbibliography
\end{document}

Compile e.g. with lualatex test.tex, biber test.bcf, lualatex test.tex, lualatex test.tex.

If you want to still use pdflatex, it would look like this:

\documentclass{scrartcl}

\begin{filecontents}{references.bib}
   @ARTICLE{test,
     TITLE = {à è ê á é},
     JOURNAL = {des accents},
     YEAR = {2015},
   }
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\usepackage[backend=biber]{biblatex}
\addbibresource{build/references.bib}

\begin{document}
  \cite{test}
  \printbibliography
\end{document}

Compile with pdflatex test.tex, biber test.bcf, pdflatex test.tex, pdflatex test.tex

  • thanks a lot, biblatex is running fine. I am using Windows (8.1) and TexMaker. Do xelatex, lualatex, fontspec and polyglossia run fine on it or is it just for linux ? Also what are their advantages over inputenc, fontenc and babel ? – etienne May 8 '15 at 20:15
  • All the above mentioned is part of miktex and texlive, which are available for windows. The big advantage of xelatex and lualatex are their native support for unicode and opentype/truetype fonts. LuaLaTeX also has build-in lua coding and metapost. – MaxNoe May 8 '15 at 20:25
  • I actually created the example on a windows 7 computer with TexLive 2014 – MaxNoe May 8 '15 at 20:29
0

It seems a problem that has been around for a while. Particularly I couldn't make both UTF-8 or latin1 to work in my document with Bibtex or Biblatex, either the characters or the bibliography, one or the other, never both. My work around was to keep the bibliography and replace the Latin characters by the Latex equivalent, for example á = \'{a}, however it is quite a lot of work to use the replace command for each accentuation. THE solution was Notepad++, which gratefully allows multiple replacement targeting the specific string:

Find:(good)|(great)|(fine)

Replace: (?1bad)(?2worse)(?3not)

Notepad++ replaces each one with the targeted word!!!

For Brazilian Portuguese in the "Replace" dialog box:

Find:(á)|(Á)|(à)|(À)|(ã)|(Ã)|(â)|(Â)|(é)|(É)|(ê)|(Ê)|(í)|(Í)|(ó)|(Ó)|(ô)|(Ô)|(õ)|(Õ)|(ú)|(Ú)|(ç)|(Ç)

Replace:(?1\'{a})(?2\'{A})(?3\`{a})(?4\`{A})(?5\~{a})(?6\~{A})(?7\^{a})(?8\^{A})(?9\'{e})(?10\'{E})(?11\^{e})(?12\^{E})(?13\'{i})(?14\'{I})(?15\'{o})(?16\'{O})(?17\^{o})(?18\^{O})(?19\~{o})(?20\~{O})(?21\'{u})(?22\'{U})(?23\c{c})(?24\c{C})

Any other language just use the specific characters.

Some details:

  1. In the 'Replace' dialog box check differentiate upper and lower case;

  2. Select regular expressions;

  3. For the 'Replace' option, if you change line before the first character, (?1\'{a})..., the replaced characters may also change lines in the text, so copy and paste the options with no line changed;

  4. Linux users can use Wine to install Notepad++ (it is not working at this time for Notepadqq, the Linux clone).

I hope it helps those that need multiple substitutions for non-English texts, once Notepad++ allows this simultaneously(!!!).

More info in

https://notepad-plus-plus.org/

https://superuser.com/questions/211011/find-and-replace-several-several-different-values-all-at-once

https://stackoverflow.com/questions/11389466/multiple-word-search-and-replace-in-notepad/16104946#16104946

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.