8

I have a BibTeX file which uses the old style LaTeX escapes, for example

author = {Fjeld, Morten and Sch\"{a}r, Sissel Guttormsen}

I want to read the file with a Scala script using jbibtex and do some stuff with the information from it. But the escapes are getting in the way, and I don't want to implement my own replacement for all possible LaTeX escapes, if I can avoid it.

Is there a tool which can be fed LaTeX or BibTeX source, will replace all escaped umlauts and other such with the correct UTF-8 characters, and spit it out without any other changes? I can imagine that my use case is somewhat exotic, but maybe such a tool exists for people who want to convert their old manuscripts to modern technology.

12

You can use biber to do this. On a command line type

biber --tool --output_encoding=UTF-8 myfile.bib

For myfile.bib containing:

@Article{Schroeder:Na,
  author =   {Schr{\"o}der, M.},
  title =    {Na{\"i}ve construction of hyper{K\"ahler} metrics},
  journal =  {{\'E}c. Norm. Sup.},
  year =     2000
}

you will get an output file myfile_bibertool.bib containing:

@ARTICLE{Schroeder:Na,
  AUTHOR       = {Schröder, M.},
  JOURNALTITLE = {Éc. Norm. Sup.},
  TITLE        = {Naïve  construction of hyper{Kähler} metrics},
  YEAR         = {2000},
}

So the German and French accents are successfully translated. As egreg notes \"i is the correct modern latex way to write the double dotted i - the old plain TeX way of \"\i will not be correctly converted by biber out of the box.

In tool mode, biber can be persuaded to do other rewriting of your source, see the biber manual texdoc biber.

  • If the ‘more correct’ input {\"i} is used, then biber is able to translate it into ï. Also hyper{K\"a}hler should be input as {hyperK{\"a}hler}. – egreg Nov 15 '13 at 11:11
  • @egreg Writing {hyperK...} prevents case change of the initial h which is usually not desirable. If using biber of course you don't need any of the brackets. You are right about \"i, but in a usual text document one needs \"\i to select the dotless i and not get a three dots at once. – Andrew Swann Nov 15 '13 at 11:16
  • 1
    Then use hyper{K{\"a}hler} (no problem with possible kerning between r and K). In normal LaTeX documents \"i produces ï: try and believe. The \i is not needed also with \'i, \^i and \`i. Other accents need \i, though. It has been so for several years, but guides forgot to note the possibility. – egreg Nov 15 '13 at 11:19
  • @egre Thanks for the information about \"i - it does indeed work. Where does one find that documented? The hyperKähler bracketing is much better. – Andrew Swann Nov 15 '13 at 11:27
  • It's documented on page 456 of the LaTeX Companion. Not really prominent, I'd say. Unfortunately, the LaTeX manual has not been updated to make people aware of the possibility. – egreg Nov 15 '13 at 11:43

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.