XeTeXClassicThesis in Russian?

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
sasasamamama
Posts: 8
Joined: Mon Dec 13, 2010 9:20 pm

ClassicThesis in Russian?

Post by sasasamamama »

Hi,

I've been trying to get Andre Miede's classic thesis template to work in Russian.

All I changed was replacing

Code: Select all

\usepackage[ngerman,american]{babel}
by

Code: Select all

\usepackage[russian,american]{babel}
and replacing the whole body by a single Russian word:

Code: Select all

...
\begin{document}
\setlanguage{russian}
куку
\end{document}
This caused the following error message:

Code: Select all

LaTeX Font Warning: Font shape `T2A/pplj/m/n' undefined
(Font)              using `T2A/cmr/m/n' instead on input line 194.

(/usr/share/texmf-texlive/tex/latex/microtype/mt-cmr.cfg) (./test.tex

! LaTeX Error: Command \DH unavailable in encoding T2A.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 
     �уку
? 
Does anyone know how to fix it?

Another problem: how do I disable chapters? There is definitely an option in the style files for that.

I tried using the LyX template of the package, but it doesn't work either (the problems are different, though).

Thank you in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

ClassicThesis in Russian?

Post by frabjous »

Since this is in the XeTeX forum, I assume you're compiling with XeLaTeX?

I don't understand what you mean by saying you only made one change. classicthesis is a package file, not a document; do you mean that's the only change you made from the stock LyX blank document using that package?

In that case, you should not use babel, but polyglossia instead.

Code: Select all

\usepackage{polyglossia}
\setdefaultlanguage{russian}
It would be a good idea to read the documentation.

You'll also want to make sure that you load a font that has the appropriate characters. Typically, with XeTeX, people use normal system fonts rather than fonts specifically made for LaTeX. For font control in XeLaTeX, see the fontspec package and its documentation. If you're not using a unicode-compliant LaTeX font, perhaps loading the xunicode package would help?

I wasn't quite sure what you meant about disabling chapters, but perhaps you had in mind something like the \includeonly command?

I don't know anything about doing this in LyX, sorry.

If you're still having trouble, please post a minimal, but still complete example (containing the complete preamble together with the document body together) of a document that is not working for you.
sasasamamama
Posts: 8
Joined: Mon Dec 13, 2010 9:20 pm

ClassicThesis in Russian?

Post by sasasamamama »

Frabjous, thank you for your reply and sorry for my late answer.

Originally the template should be compiled with pdfLaTeX, but I tried to compile it with XeLaTeX, which does not work (I was following these instructions). It says some particular files and fonts cannot be loaded, and probably it was a bad idea to use XeLaTeX. It was also my mistake to post it in the XeTeX forum, I am sorry.
But do you think I should continue and make it work with XeLaTeX (as I need it in Russian and probably will have to load some different fonts)? Or with pdfLaTeX?
Anyway, I'm not sure it would be a good idea to saddle you with minimal examples, but just in case you would need them to answer anything, please find one attached.
I don't understand what you mean by saying you only made one change. classicthesis is a package file, not a document; do you mean that's the only change you made from the stock LyX blank document using that package?
It is not a LyX document, just .tex files. I tried to configure them so that they would work with Russian and XeLaTeX.
I wasn't quite sure what you meant about disabling chapters, but perhaps you had in mind something like the \includeonly command?
I would not like to use chapters in my paper at all, but only (sub)sections instead.
Attachments
minimal.tar.gz
(9.86 KiB) Downloaded 489 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

ClassicThesis in Russian?

Post by frabjous »

Actually, the minimal example is extremely helpful. It's nice to have something to play around with.

I think you should be able to get this working with either pdflatex or xelatex. Here are some suggestions depending on which one of these you choose.

For PDFLaTeX, edit ClassicThesis.tex as follows:
  1. Remove all the xelatex specific stuff. In particular, remove the line:

    Code: Select all

    \usepackage{fontspec}
    
    and the lines

    Code: Select all

    \usepackage{polyglossia}
    \setdefaultlanguage{russian}
    
  2. Now, be sure to set things up for the proper character encoding. I don't think latin1 supports Cyrillic characters. For me. What worked for me is to change the line:

    Code: Select all

    \usepackage[latin1]{inputenc}
    
    to

    Code: Select all

    \usepackage[utf8]{inputenc}
    
    That gave me Unicode input encoding, which works for Cyrillic. However, I'm using linux and my editor uses UTF-8/Unicode. Yours may not. According to this (which may be dated in not mentioning utf8), some other things to try in place of "utf8" are "koi8-r" and "cp1251". It'll depend on your operating system, regional and text editor settings.
  3. Now add a line right underneath that one:

    Code: Select all

    \usepackage[russian]{babel}
    
After making those changes I was able to compile your document without any errors. I did get a warning about font substitution. It appears that the font that classicthesis.sty wants to load doesn't have Cyrillic characters, but it replaces them with the ones from the default font, which may or may not be OK with you. (I don't really know off hand which LaTeX fonts have Cyrillic characters and which don't, since I don't use them very often.)

For XeLaTeX, edit ClassicThesis.tex as follows:
  1. Simply remove the line:

    Code: Select all

    \usepackage[T1]{fontenc}
    
    with no replacement. XeLaTeX expects Unicode input by default and no package is necessary. Leave the fontspec and polyglossia stuff in there.
  2. In between the two polyglossia lines you have, add a line to specify the font to be used. This can be any font on your system that have these characters. Do this using the \newfontfamily command from fontspec. For me, it looked like this:

    Code: Select all

    \usepackage{polyglossia}
    \newfontfamily\cyrillicfont[Script=Cyrillic]{DejaVu Serif}
    \setdefaultlanguage{russian}
    
    You can use any other font you like -- and of course you must pick another one if you don't have DejaVu Serif installed.
After that, your document compiled fine for me with xelatex. Of course you need to be sure that your editor is configured to compile with xelatex, rather than pdflatex. What you wrote about certain packages not being available made it sound as if you tried to compile with pdflatex rather than xelatex.
I would not like to use chapters in my paper at all, but only (sub)sections instead.
Apparently the classicthesis package has a "nochapters" option. Just change your line:

Code: Select all

\usepackage[eulerchapternumbers... ]{classicthesis}
to

Code: Select all

\usepackage[nochapters... ]{classicthesis}
I think that should work, but I haven't tested. It seems very strange to have a package do that rather than a documentclass, but the classicthesis template itself looks like a mess to me. But that's a topic for another occasion.
sasasamamama
Posts: 8
Joined: Mon Dec 13, 2010 9:20 pm

ClassicThesis in Russian?

Post by sasasamamama »

Frabjous, thank you so much. At last my 'куку' has been printed. Only with PDFLaTeX, though. With XeLaTeX, it didn't.

To know how to remove chapters is also great. But the \section command didn't work for PDFLaTeX.

I attached my changes together with the log files, probably you could have a look?
You can use any other font you like -- and of course you must pick another one if you don't have DejaVu Serif installed.
I have this font.
Attachments
minimal_xelatex.tar.gz
(19.35 KiB) Downloaded 514 times
minimal_pdflatex.tar.gz
(21.77 KiB) Downloaded 523 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

ClassicThesis in Russian?

Post by frabjous »

For the pdflatex version, you seem to be having the same problem discussed here -- apparently in order to use classicthesis with utf8 characters in section titles (--notice there's no problem if you use unaccented latin letters only--), you need to use the pdfspacing option for the package. You have that option commented out, but it seemed to work if you uncomment that option.

I noticed, however, that even with nochapters it seems to want to print a 0 for the chapter number before the section number anyway. I guess you could fix that by putting:

Code: Select all

\renewcommand{\thesection}{\arabic{section}}
right before \begin{document}. This should suppress that 0.

For the XeLaTeX version, it's a bit trickier, since I cannot recreate the problem. When I compile your file, I don't get that error. (And it fully stops compilation: so it's not that you aren't getting the Cyrillic characters; no file is being created at all.) I guess there are some differences in our set ups. I'm not sure what it is. (You're using TeXlive 2009 for Debian/Ubuntu; I'm using TeXlive 2010 installed from TUG, though I don't think that alone explains it.)

Looking at your log, however, the problem seems to have something to do the pplj font, which is one of the Palatino fonts classicthesis wants to load with the mathpazo package. Especially since you're overriding that font anyway, it hardly seems like it should matter. But it does. Since you're modifying the .sty file anyway (and creating a local version), you might try modifying it further by removing the line (line 187):

Code: Select all

\RequirePackage[osf,sc]{mathpazo} % Palatino with real small caps and old style figures
from classicthesis.sty (--you want want to remove the line after it too depending on the font you end up picking and whether it seems to require greater line spacing).

Probably you'd need the other changes above for handling the section numbers and titles here too.

Good luck!
-
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

ClassicThesis in Russian?

Post by frabjous »

OK, for the XeLaTeX version, I was able to test it on my wife's computer, where I have the Debian/Ubuntu version of TeXlive 2009 installed, and there, I could duplicate your problem. It appears that to solve the problem, a few more steps are needed. First, in addition to removing the mathpazo line mentioned above, you'll also need to change (lines 200-202) in classicthesis.sty:

Code: Select all

\ifthenelse{\boolean{@eulerchapternumbers}}% font for the chapter numbers
    {\newfont{\chapterNumber}{eurb10 scaled 7000}}%
    {\newfont{\chapterNumber}{pplr9d scaled 7000}}  
to

Code: Select all

\ifthenelse{\boolean{@eulerchapternumbers}}% font for the chapter numbers
    {\newfont{\chapterNumber}{eurb10 scaled 7000}}%
    {}  
I.e., delete the inner part of the second braces.

Also, in ClassicThesis.tex, you'll need to:
  1. Add another line for font control to set the main font and not just the Cyrillic font:

    Code: Select all

    \usepackage{polyglossia}
    \newfontfamily\cyrillicfont[Script=Cyrillic]{DejaVu Serif}
    \setdefaultlanguage{russian}
    
    to, for example:

    Code: Select all

    \usepackage{polyglossia}
    \setmainfont{DejaVu Serif}
    \newfontfamily\cyrillicfont[Script=Cyrillic]{DejaVu Serif}
    \setdefaultlanguage{russian}
    
  2. Remove the beramono and eulermath options to classicthesis and add the pdfspacing option, as above.
  3. Change the numbering scheme for chapters as above. You should also add the nochapters option to the classicthesis-ldpkg, though I don't know what difference that makes.
That seems to work, though making all these changes makes me nervous, and makes me worry that more problems may lie around the corner if you want to use this package with XeLaTeX.
sasasamamama
Posts: 8
Joined: Mon Dec 13, 2010 9:20 pm

Re: ClassicThesis in Russian?

Post by sasasamamama »

Now it really does compile for both pdflatex and xelatex. It seems that not much is left from the original design. For example, the section title looks very different from the original now, not only because of the font.
Apparently it is necessary to write a new template for those who want to use classicthesis in Russian.

Nevertheless, thank you very much for your help and patience!
Post Reply