3

In the following simple document, the bibliography does not work :

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{inputenc}

\inputencoding{utf8}
\begin{filecontents}{\jobname.bib}
\input{references_utf8}
\end{filecontents}
\inputencoding{latin1}

\begin{document}
\noindent
\cite[voir][chap. 12]{2009solar}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

I want to do this because my main documents are in latin-1 and the .bib file is in utf-8. The idea of using \inputencoding was recommended in this question : How to convert UTF-8 to latin-1 on the fly?.

The file references_utf8.bib looks like this :

@book{2009solar,
address = {New Delhi},
author = {Solanki, Chetan Singh},
booktitle = {Solar Photovoltaics: Fundamentals, Technologies and Applications},
chapter = {12},
edition = {1},
isbn = {9788120337602},
pages = {478},
publisher = {Prentice-Hall of India},
title = {{Solar Photovoltaics: Fundamentals, Technologies and Applications}},
url = {http://books.google.ca/books?id=hdvYA9KsI2YC},
year = {2009}
}

But it has to be encoded in utf-8.

How can I make this setup work?

4
  • it does make sense to input a bib. Put the \inputencoding command before the \bibliography command (which loads the bbl) Aug 20, 2012 at 21:59
  • I think I narrowed down the problem : commands like \input{references_utf8} inside the environment filecontents are NOT executed by latex, but simply copied verbatim in the file \jobname.bib. This is not what I want : If the command culd be executed, I think the whole code would work.
    – jul059
    Aug 20, 2012 at 22:38
  • No. You are on the completly wrong track. You don't need a \jobname.bib. bibtex will use your original references.bib to create a \jobname.bbl. And your document will then input this bbl when you use the \bibliography command. Open the bib and the bbl in your editor to see the differences! Aug 21, 2012 at 8:03
  • If your bib file is as you show with all ascii characters you do not need any encoding switch. That file is already ascii, utf8 and latin1: the encodings are identical in that range. What made you think you needed to change the input encoding? Aug 21, 2012 at 20:55

1 Answer 1

2

bibtex cannot handle utf8 characters. With bibtex8 some utf8 characters are possible, eg umlauts. However, you can change the inputencoding:

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage[latin1]{inputenc}

\begin{document}
\noindent
\cite[voir][chap. 12]{2009solar}

\begingroup
\iputencoding{utf8}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\endgroup
\end{document}
2
  • As you can see, the .bib file does not contain any special characters. It seems to be simply a matter of what type of encoding is specified in the file (is this how it works? is there a "specified type"?). In my .bib file, if I have special special characters they will we coded with the latex command. For example, é will be coded \'{e} so this should not be a problem.
    – jul059
    Aug 20, 2012 at 21:01
  • it should be coded as {\'e}
    – user2478
    Aug 21, 2012 at 5:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .