4

I was passing some documents I had in HTML to LaTeX for a better printout. While the main language of those documents is Spanish (and a few more are in English) there have snips in other languages, including languages that do not use Latin-1, such as Greek and IPA extensions.

Here is a minimal working example of what I am doing.

\documentclass[12pt]{book}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}
\Large
El término democracia viene del griego \textit{δημοκρατία} 
(pronunciado \textsf{/ðimokɾatía/}) y que significa gobierno
del pueblo.
\end{document}

The document is correctly encoded in UTF-8 (I've check with low-level tools).

When attempting to compile using pdflatex I get the following error fore each of the non-latin-1 characters.

! Package inputenc Error: Unicode char \u8:δ not set up for use with LaTeX.

And, indeed, those glyphs do not appear in the document:democracia-pdflatex

Supposedly xelatex should correct this problems, as it is supposedly Unicode-ready, however, with the same code I get the following errors:

! Package inputenc Error: Unicode char \u8:érm not set up for use with LaTeX.
! Package inputenc Error: Unicode char \u8:ðimo not set up for use with LaTeX.
! Package inputenc Error: Unicode char \u8:ía/ not set up for use with LaTeX.

(It does not report error in the Greek or IPA characters, only in the Latin-1 extended ones)

Neither these reported character groups, neither the Greek characters appear in the produced document:democracia-xelatex

I have isolated the xelatex error to the inputenc package. If I comment out that package the document compiles smoothly (the same happens with lualatex). Still the Greek and IPA characters do not appear.democracia-xelatex without inputenc

(And, of course, without inputenc the pdflatex compilation, while not reporting any error, does not behave well either, I presume it is mapping each byte to the T1 encoding):democracia-pdflatex without inputenc

So, there are actually two questions:

  1. How can I get to correctly get the Greek and IPA (and probably other non-Latin characters) to appear in my document bot using pdflatex and (xe/lua)latex?

  2. How can I mask the inputenc so that it loads with pdflatex but not with (xe/lua)latex?

1
  • 2
    To use unrestricted UTF8 you should really be using either XeLaTeX or LuaLaTeX, in which case you don't need inputenc or fontenc at all.
    – Alan Munn
    Commented Nov 29, 2013 at 15:16

1 Answer 1

5

You have to teach LaTeX how to switch to Greek and also to IPA. Moreover, the translation of Unicode to IPA is not complete and, in particular ɾ (U+027E LATIN SMALL LETTER R WITH FISHHOOK) is not available by default.

Using Greek is solved by loading the greek module for babel; support for IPA with the tipa package; the missing translation can be added with newunicodechar.

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[greek,spanish]{babel}
\usepackage{tipa}

\usepackage{newunicodechar}
\newunicodechar{ɾ}{\textfishhookr}

\begin{document}
El término democracia viene del griego
\textit{\foreignlanguage{greek}{δημοκρατία}}
(pronunciado \textsf{\textipa{/ðimokɾatía/}})
y que significa gobierno del pueblo.
\end{document}

enter image description here

If you want a document compilable both with pdflatex and xelatex you should define commands for the constructs and provide different definitions according to what engine is used. Here's a way.

\documentclass[12pt]{book}
\usepackage{ifxetex}

\ifxetex
  \usepackage{fontspec}
  \setmainfont[Ligatures=TeX]{Linux Libertine O}
  \setsansfont[Ligatures=TeX]{Linux Biolinum O}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{tipa}
  \usepackage{newunicodechar}
  \newunicodechar{ɾ}{\textfishhookr}
\fi

\usepackage[greek,spanish]{babel}

\newcommand{\GR}[1]{\foreignlanguage{greek}{#1}}

\ifxetex
  \newcommand{\xIPA}[1]{\mbox{\textsf{/#1/}}}
\else
  \newcommand{\xIPA}[1]{\textsf{\textipa{/#1/}}}
\fi

\begin{document}
El término democracia viene del griego 
\textit{\GR{δημοκρατία}}
(pronunciado \xIPA{ðimokɾatía})
y que significa gobierno del pueblo.
\end{document}
3
  • While my example only uses the fishhooked r, my actual document use much more IPA characters. Should I add them manually or are there a way to include them all (or most of them) in one command? Commented Nov 29, 2013 at 16:12
  • @CarlosEugenioThompsonPinzón I'm afraid you have to go one for one. Type them and look which ones give problems.
    – egreg
    Commented Nov 29, 2013 at 16:18
  • Thank you for the answer @egreg. I finally got the Greek, IPA (and a few other Unicode glyphs) correctly, after downloading texlive-lang-greek and solving other related problems. It is now compiling with pdflatex. In xelatex is working too but it reports that file greek-fontenc.def is missing. Commented Nov 29, 2013 at 18:24

You must log in to answer this question.

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