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 am trying to do a book which has its main language as Russian. The problem is that on the second compiler run on TeXShop (LaTeX document) when it needs to create the bookmarks in Russian, it struggles with the characters for some reason. This same code works when I use it with a text in English, so I need to figure out how to handle the Russian.

I'm a bit new to TeX and would appreciate your help very much.

This is a shortened example of my code:

\documentclass[a5paper]{book}
\usepackage{graphicx}
\usepackage[left=1cm, right=1cm, top=1.5cm, bottom=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T2B]{fontenc}
\usepackage[pdftex]{hyperref}
\hypersetup{
    unicode=true,
    colorlinks=true,
    citecolor={black},
    linkcolor={black},
    urlcolor={black},
    pdffitwindow=true,
}
\usepackage[none]{hyphenat}
\sloppy

\begin{document}
\frontmatter
    % Titlepage
    \title{
        \Huge{\textbf{БИБЛИЯ}}\\\vspace{0.05cm}
    \author{} \date{}
    }
    \pdfbookmark[0]{Title Page}{title}
    \maketitle

\mainmatter
\begin{center}
\pdfbookmark[0]{Бытие}{Бытие}\noindent\\
\vspace{0.15cm}\textbf{\Huge{Бытие}}\vspace{0.00cm}\\
\end{center}
\pdfbookmark[1]{1}{Бытие1}\noindent\Large{Глава 1}\\\\
\normalsize 1 \Large \indent В начале сотворил Бог небо и землю.\\
\normalsize 2 \Large \indent Земля же была безвидна и пуста, и тьма над бездною, и Дух Божий носился над водою.\\

\pdfbookmark[1]{2}{Бытие2}\noindent\Large{Глава 2}\\\\
\normalsize 1 \Large \indent Так совершены небо и земля и все воинство их.\\
\normalsize 2 \Large \indent И совершил Бог к седьмому дню дела Свои, которые Он делал, и почил в день седьмый от всех дел Своих, которые делал.\\

\begin{center}
\newpage\pdfbookmark[0]{1-e Иоанна}{1-e Иоанна}\noindent\\
\vspace{0.15cm}\textbf{\Huge{1-e Иоанна}}\vspace{0.00cm}\\
\end{center}
\pdfbookmark[1]{1}{1-e Иоанна1}\noindent\Large{Глава 1}\\\\
\normalsize 1 \Large \indent О том, что было от начала, что мы слышали, что видели своими очами, что рассматривали и что осязали руки наши, о Слове жизни, –\\
\normalsize 2 \Large \indent ибо жизнь явилась, и мы видели и свидетельствуем, и возвещаем вам сию вечную жизнь, которая была у Отца и явилась нам, –\\

\pdfbookmark[1]{2}{1-e Иоанна2}\noindent\Large{Глава 2}\\\\
\normalsize 1 \Large \indent Дети мои! сие пишу вам, чтобы вы не согрешали; а если бы кто согрешил, то мы имеем ходатая пред Отцем, Иисуса Христа, праведника;\\
\normalsize 2 \Large \indent Он есть умилостивление за грехи наши, и не только за наши, но и за грехи всего мира.\\

\end{document}

This is a small part of the log output showing the error:

(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/gettitlestring.sty
Package: gettitlestring 2010/12/03 v1.4 Cleanup title references (HO)
) \c@section@level=\count108 ) LaTeX Info: Redefining \ref on input
line 18. LaTeX Info: Redefining \pageref on input line 18. LaTeX Info:
Redefining \nameref on input line 18.

(./ATest.out ./ATest.out:3: Undefined control sequence.  \T 
              2B\CYRB \T 2B\cyrery \T 2B\cyrt \T 2B\cyri \T 2B\cyre .0
l.3 ...2B\cyrery \T2B\cyrt \T2B\cyri \T2B\cyre .0}
                                                  % 3 ? 
./ATest.out:3: Missing \endcsname inserted.  
                   \T2B\CYRB  l.3 ...2B\cyrery \T2B\cyrt \T2B\cyri
\T2B\cyre .0}
                                                  % 3 ? 
./ATest.out:3: Undefined control sequence.  \T 
              2B\CYRB \T 2B\cyrery \T 2B\cyrt \T 2B\cyri \T 2B\cyre .0
l.3 ...2B\cyrery \T2B\cyrt \T2B\cyri \T2B\cyre .0}
                                                  % 3 ?
share|improve this question
    
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Andrey Vihrov Aug 6 '11 at 11:11

2 Answers 2

up vote 8 down vote accepted

Your original problem is solved by avoiding Cyrillic in PDF bookmark names. The reason for this is that with inputenc UTF-8 characters are something more than just characters. Instead of

\pdfbookmark[0]{Бытие}{Бытие}

write

\pdfbookmark[0]{Бытие}{Genesis}

However, it is easier to use the higher level \addcontentsline command, which not only adds an entry to the PDF TOC, but also to the LaTeX's primary table of contents, should it be printed:

\addcontentsline{toc}{chapter}{Бытие}

If you are going to do much work in Russian, you can also consider using the XeTeX engine instead of the default pdfTeX. XeTeX supports Unicode natively and allows to load any TrueType or OpenType font. Since XeTeX doesn't rely on tricks to work with UTF-8 and rather processes Unicode-encoded text directly, it is also possible to use Cyrillic (or any other) characters in PDF bookmark names and control sequence names (compile with xelatex instead of pdflatex or latex; polyglossia is the XeLaTeX replacement for babel):

\documentclass{book}

\usepackage{polyglossia}
\usepackage{hyperref}

\setdefaultlanguage{russian}
\newfontfamily\russianfont[Ligatures=TeX]{CMU Serif}

\begin{document}

\chapter{Проверка}
\pdfbookmark{Ещё проверка}{Название закладки}

\end{document}

See also this, this and this question.

Finally, I should also note that using low-level formatting commands over and over is not a good style and will soon bite you. You should, perhaps after reading some LaTeX tutorials (try also this exceptionally good, if not a bit old, book in Russian), define commands with semantic names and use them. You may also want to look at the titlesec package.

share|improve this answer
    
Thanks Andrey, I've implemented your suggestions and it works great. I appreciate the help. –  McGafter Aug 10 '11 at 11:45

For same purpose I load the hyperref package with the option unicode independantly of input encodings.

share|improve this answer

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.