6

EDIT: In the end I ended up using XeTeX (with auto-refreshing Evince viewer) - as suggested by @Andrey Vihrov. I am, however, accepting the most upvoted answer.

I am lost. Looked all over tex.stackexchange and can't find a good solution. Only suggestions to use babel or xetex...

I want to be able to use BOTH russian (cyrillic) and unicode characters in my latex source files. For example, this does not compile:

In Dahl’s dictionary there is a similar sounding word “дуван”...
“C’est auprès de son père, écrivain de la nation pisane à la douane de Bougie, à
la fin du douzième siècle[todo], que le célèbre mathématicien Léonard Bonacci...

If I use babel and set it to russian for above, the compiler pukes on the other non-russian unicode chars. If I set babel to english - then the russian does not work:

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

Please note, I don't really care for "hyphenation" and such - I can do that myself manually if need be. I just want my source documents to compile into lagex.

The problem is my main document is typeset in english, with a lot of different quotes that have languages ranging all across Europe.

Is this possible with only LaTeX (dvi)? Or must I resort to something else? I would very much prefer to stay in LaTeX - as all my compile tools are setup for it.

Either way, I would appreciate some advice.

8
  • 7
    Many languages is a perfect application of XeTeX. Why would you not want to use it? Mar 4, 2012 at 22:21
  • 1
    That is a different question, the one I am not really asking ;-) tex.stackexchange.com/search?q=latex+xetex Mar 4, 2012 at 23:54
  • At the risk of being too intrusive, may I ask for your reasons to not use XeTeX or LuaTeX? Mar 5, 2012 at 13:15
  • Sorry, I didn't meant to be rude ;-) Basically it's because I use vim-latex plugin, and it's setup to run LaTex and preview in Yap (which is dvi previewer). What I love about this setup, is when I recompile my document, yap automatically refreshes - but keeps the location in the document (i.e. when I recompile my book, I don't have to navigate to page 245 again!) Mar 5, 2012 at 16:07
  • 1
    You should be able to switch easily. Googling shows results on how to use XeTeX with VIM-LaTeX, and for the previewer you can use Evince (it auto-refreshes and is available for Windows). You should even be able to get SyncTeX to work. And this website has many examples for XeTeX (like this one). Mar 5, 2012 at 17:33

2 Answers 2

15

You need to announce LaTeX the languages you intend to use (T2A is for cyrillic):

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,french,english]{babel}

\begin{document}

In Dahl’s dictionary there is a similar sounding word “\foreignlanguage{russian}{дуван}”.

\begin{otherlanguage*}{french}
“C’est auprès de son père, écrivain de la nation pisane à la douane de Bougie, à
la fin du douzième siècle[todo], que le célèbre mathématicien Léonard
Bonacci
\end{otherlanguage*}

\end{document}

enter image description here

The main problem is that fonts have only 256 slots available for glyphs and writing in French and Russian requires more than 256 glyphs. (Maybe this is not strictly true, but even if the number of glyphs were less than 256, a special output encoding for French and Russian would be needed; what about German and Russian, Polish and Russian, or a mixing of three languages?)

You can always define an abbreviation, say \RUS, for typesetting isolated words in Russian

\newcommand{\RUS}[1]{\foreignlanguage{russian}{#1}}

(or, more efficiently, \newcommand{\RUS}{\foreignlanguage{russian}}). You have the benefit that hyphenation will be correct.

A different approach requires using an OpenType font that contains all the needed glyphs, but of course XeLaTeX or LuaLaTeX with fontspec are required.

1
  • That seems like a lot of foreignlanguage commands... especially if I have a lot of different quotes in different languages. I was hoping latex unicode would be able to figure things out by itself by now :-( Mar 5, 2012 at 6:26
7

As extension to egreg's answer: babel and \foreignlanguage are not really needed to print cyrillic. The main point in his answer is the T2A: It tells latex that you wants to use cyrillic in your document and so latex activates the needed definitions for the utf8 (don't forget that there are a lot chars in unicode, it would slow down latex a lot if it would load definitions for all of them everytime).

You will still have to change to the font encoding T2A before using the cyrillic. You can avoid this by setting up defaults:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}%
%\usepackage[russian,french,english]{babel}
\DeclareTextSymbolDefault{\cyrd}{T2A}
\DeclareTextSymbolDefault{\cyru}{T2A}
\DeclareTextSymbolDefault{\cyrv}{T2A}
\DeclareTextSymbolDefault{\cyra}{T2A}
\DeclareTextSymbolDefault{\cyrn}{T2A}
% etc
\begin{document}

In Dahl’s dictionary there is a similar sounding word дуван.

C’est auprès de son père, écrivain 


\end{document}
1
  • This has the drawback that \UseTextSymbol is expanded once for any cyrillic character; with many cyrillic words it would introduce a heavy overhead.
    – egreg
    Mar 5, 2012 at 9:34

You must log in to answer this question.

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