Archive for September 25th, 2010

Using the classicthesis package with XeLaTeX

Compiling an article or anything else with classicthesis package will return errors. Indeed, something written and compiled with the classicthesis package loaded must be compiled with pdflatex (and maybe also latex, I don’t know).

Anyway, here is a little trick to compile your documents with XeLaTeX using your prefered template. First of all, we have to make a backup of our file classicthesis.sty. If you use Ubuntu and have installed TeXlive with your package manager, do as follows either with a terminal or your file manager with root privileges (for this, type Alt+F2 and enter gksu nautilus in the prompt) :

sudo cp /usr/share/texmf-texlive/tex/latex/classicthesis/classicthesis-ldpkg.sty /usr/share/texmf-texlive/tex/latex/classicthesis/classicthesis-ldpkg_backup.sty

If you have installed TeXlive with the installation script install-tl, then do as follows :

sudo cp /usr/local/texlive/2010/tex/latex/classicthesis/classicthesis-ldpkg.sty /usr/local/texlive/2010/tex/latex/classicthesis/classicthesis-ldpkg_backup.sty

Then, open classicthesis-ldpkg.sty in a text editor, let say gedit. If you have installed TeXlive with your package manager :

gksu gedit /usr/share/texmf-texlive/tex/latex/classicthesis/classicthesis-ldpkg.sty

And if not :

gksu gedit /usr/local/texlive/2010/tex/latex/classicthesis/classicthesis-ldpkg.sty

In this file, you will have to comment the following lines :

% ********************************************************************
% Using PDFLaTeX:
% ********************************************************************
\RequirePackage[pdftex,hyperfootnotes=false,pdfpagelabels]{hyperref} % backref linktocpage pagebackref
\pdfcompresslevel=9
\pdfadjustspacing=1
\RequirePackage[pdftex]{graphicx} % PDFTeX driver for graphicx
%\DeclareGraphicsRule{*}{mps}{*}{} % enables use of MetaPost graphics with pdflatex

%*******************************************************
% for German texts to get \autoref macros right
\renewcommand{\figureautorefname}{Figure}
\renewcommand{\tableautorefname}{Table}
\renewcommand{\partautorefname}{Part}
\renewcommand{\chapterautorefname}{Chapter}
\renewcommand{\sectionautorefname}{Section}
\renewcommand{\subsectionautorefname}{Section}
\renewcommand{\subsubsectionautorefname}{Section}

Then, save your file. Here is a screenshot of what I get after commenting on the left side, and before on the right side :

That’s all, folks ! Now if you compile a file with XeLaTeX using the classicthesis package, it will work. I will write soon a post about it, and will show you a sample of file I have successfully compiled.

EDIT : There is no need to comment the lines :

\renewcommand{\figureautorefname}{Figure}
\renewcommand{\tableautorefname}{Table}
\renewcommand{\partautorefname}{Part}
\renewcommand{\chapterautorefname}{Chapter}
\renewcommand{\sectionautorefname}{Section}
\renewcommand{\subsectionautorefname}{Section}
\renewcommand{\subsubsectionautorefname}{Section}

But in order to get mathematical symbols working with the specific setup of XeLaTeX, we have to comment the following lines :

{%
% default: Palatino
\RequirePackage[osf,sc]{mathpazo} % Palatino with real small caps and old style figures
\linespread{1.05} % a bit more for Palatino
}

Which are in the file classicthesis.sty, lines 183-187 (don’t forget to comment the “{” l. 183). With that, everything will work fine with math font setup and unicode-math with XeLaTeX.

Advertisement

XeLaTeXで書く仕方 ・ Writing in japanese with XeLaTeX

  • 日本人であれば、XeLaTeXを使っていいです。長い説明するより簡単な例を示します。
  • \documentclass{article}
    \usepackage{xltxtra} %xltxtra = fontspec, xunicode, etc.
    \usepackage{verbatim}
    \usepackage{url}
    \setmainfont{IPA明朝}
    \linespread{1.05}
    \newfontfamily\en[Numbers=OldStyle,Ligatures=Historic]{TeX Gyre Pagella}
    \begin{document}

    日本語で書くためにはIPA明朝を使っていいです。しかし、時々英語などで書
    く機会があります。その時、
    \begin{verbatim}
    \verbatim{\en your text goes here}
    \end{verbatim}
    を入力したら、英語のためのフォントで書ける。

    たとえば、{\en here is a test to show you how writing both in
    english and in japanese is easy with \XeLaTeX. Of course, you can also mix any
    other languages you want.}

    {\en \XeLaTeX}に関しては次の{\en url}を参照してください:

    \url{http://tug.org/xetex/}
    \end{document}

    以上のファイルをXeLaTeXでコンパイルしてください。そうするようにTeXworksを使って、XeLaTeXを選択して、緑色のボタンを押すとpdfファイルを得る。

    以上は簡単な例だけです。私の場合は日本語の文書を書く必要がなくて、ただ混じられた言語のあるテキストを書けたいのです。日本語の論文を書く人であったら、polyglossiaパッケージを使っていいのではないかと思います。そのためにこのサイトを参照してください。

  • If you plan to write english text with some japanese text or quotes included in your text, and not an entire text in japanese, then you should only put the following command in your preamble :

    \newfontfamily\ja{IPA明朝}

    This way, you will just have to insert {\ja } and to typeset japanese inside the {}. Therefore if you wish to write, in your english text 一言だけ, you have to do like this {\ja 一言}. As an example of my short explanation, you can try to compile the following file :

    \documentclass{article}
    \usepackage{xltxtra} %xltxtra = fontspec, xunicode, etc.
    \setmainfont{TeX Gyre Pagella}
    \newfontfamily\ja{IPA明朝}
    \begin{document}
    Here is an english sentence, followed by {\ja 日本語の例。} \XeLaTeX {\ja は便利ですね。}
    \end{document}

    Here is a screenshot showing the output and the .tex file :

%d bloggers like this: