Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have my whole latex document which is encoded in latin-1. Also, the documentclass provided by my institution is designed to use latin-1. I write in french.

I wish to use .bib files created by Mendeley which are encoded in UTF-8. When I try to compile, latex gives me an error :

inputenc: Keyboard character used is undefined(inputenc) in inputencoding `latin1'.

Is there a way to convert the encoding on the fly with a simple command? Here is my setup :

Windows 7

MiKTeX 2.9

TexStudio 2.3

Mendeley to export my .bib

It's just a matter of changing the encoding since if I simply copy the content of the .bib file in a new file (with the right encoding setup in TexStudio), everything works fine. I don't want to do that since it breaks my workflow. I'm thinking of something like a command to add before the execution of pdflatex.

share|improve this question
1  
Menderleyshould be able to create file with ansi encoding. But better would be to use utf8 in all your files. Then change input encoding to utf-8. –  Kurt Aug 19 '12 at 22:45
    
@Kurt Do you know how to force Mendeley to output something different than UTF-8? –  jul059 Aug 19 '12 at 22:56
    
Incidentally, Texstudio is heavily based (to put it charitably) on Texmaker, so you may want to go to the source. –  MatteoS Aug 19 '12 at 22:59
    
@jul059: No I don't because I deleted the program. I do not agree to download to this company any document I'm using. For me data protection is too important. Why do you insist on Latin1? But you can do the change with your editor. Load the utf-8 bib file and change it to the encoding you need. TeXstudio can do this for you. –  Kurt Aug 19 '12 at 23:13
    
@Kurt as I said, this breaks my workflow. –  jul059 Aug 19 '12 at 23:19
show 3 more comments

3 Answers 3

You don't need to reencode your files. LaTeX is quite able to input an utf8 encoded file in ansinew/latin1 encoded main file:

....
\inputencoding{utf8}
\input{utf8file}
\inputencoding{ansinew} %back to ansinew
....

But if you are using biblatex/biber you probably don't have to worry at all: If your bib-file contains only chars which are also covered by ansinew, then biber will convert the utf8 to ansinew when generating the bbl. This here works without problem for me: (the bib contains german umlauts.)

\documentclass[12pt]{article}
\usepackage[ansinew]{inputenc}
\usepackage[bibencoding=utf8]{biblatex}
\addbibresource{examples-utf8.bib}
\begin{document}
öäü
\cite{utf8test}
\printbibliography
\end{document}

Btw: On windows you should normaly use ansinew instead of latin1 so that e.g. also the € is processed correctly.

share|improve this answer
2  
Nice one: \usepackage[bibencoding=utf8]{biblatex} –  MatteoS Aug 20 '12 at 9:34
    
Thanks, this is very nice. Is there a reason why I can't use this : \inputencoding{utf8} \bibliography{bibfile} \inputencoding{ansinew} I want to use bibtex and natbib since my institution's template was built with that system. –  jul059 Aug 20 '12 at 14:32
    
bibtex is an 8bit engine so it processes every file in 8-bit pieces. In utf8 non-ascii chars are longer than 8 bit so they are splitted by bibtex. This means that bibtex has problems to sort references with non-ascii chars correctly. It can also happen that bibtex inserts a line break in the middle of an utf8-char and then you will get errors. –  Ulrike Fischer Aug 20 '12 at 14:49
add comment

For this purpose I usually use a text editor like Sublime . It allows to load or save text files (or .tex files, of course) in the desired encoding.

The Latin1 encoding in Sublime uses the ISO/IEC name ISO 8859-1 .

Depending on your problem, you may want to use a LaTeX editor that automatically recognises font encodings, like Texmaker, for instance

share|improve this answer
    
Changing to Texmaker does not solve the problem, still the same error. It seems that even though the encoding is detected, It does not work since they are not all in the same encoding. –  jul059 Aug 19 '12 at 23:13
add comment

Since your whole workflow seems to be designed to work with Latin1, the question would then rather be how to get rid of UTF-8 in your workflow (even though it is quite sad to do so).

Then I think since .bib files are all the same, maybe you would want to just plain change your references manager to something that supports changing the output encoding and that still works for you (instead of changing the output encodings of your current manager, which seems not to be obvious).

For references managment, I use for myself JabRef. It is capable of changing the output encoding very easily and is quite easy to use as well as multi-platform.

Maybe this would be worth trying ?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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