Archive for the ‘ XeLaTeX ’ Category

Writing math with XeLaTeX

The following is a short explanation for those who wish to get the basics to write math with XeLaTeX :

  • First, you will notice, if you look at the xelatex directory, that there is a mathspec folder. If you don’t know where is your xelatex folder, then look here if you have installed TeXlive with the installation script :

    /usr/local/texlive/2010/texmf-dist/doc/xelatex/mathespec/

    Or look here if you have installed TeXlive with your package manager :

    /usr/share/doc/texlive-doc/xelatex/mathspec/

  • But a better choice might be to use unicode-math, though it is still in its beta stage. Documentation about this package is located in the following directory in case you have installed TeXlive with the installation script install-tl :

    /usr/local/texlive/2010/texmf-dist/doc/latex/unicode-math

    Or here if you have installed TeXlive with your package manager :

    /usr/share/doc/texlive-doc/latex/unicode-math

  • Let us assume you wish to use the unicode-math package. Then, you will have to load it :

    \usepackage{unicode-math}

    And to define the font for math :

    \setmathfont{Asana Math}

    Consequently, here is an example of minimal preamble to write math and compile with XeLaTeX :

    \documentclass{article}
    \usepackage{unicode-math}
    \usepackage{amsmath}
    \usepackage{xltxtra}
    \setmainfont{TeX Gyre Pagella}
    \setmathfont{Asana Math}

    Where article is a class to make a test, unicode-math the package to input math with XeLaTeX, amsmath the usual package for math and xltxtra the usual package for XeLaTeX which load some useful modules (see the xltxtra for a list of these modules).
    Also, \setmainfont{TeX Gyre Pagella} is the definition of the font for your text, and \setmathfont{Asana Math} the definition of the fonts for math as I said previously.

Here is a screenshot of an example of output (a pdf file) we can get with XeLaTeX :

Writing an application letter with XeLaTeX

With LaTeX, several packages are dedicated for letters. For french TeX users, there is for example the class lettre, which might be widely used. For english TeX users, the letter written with the letter class or with koma-script might be also used.

Also, notice that the structure of a letter should be as follows :

Here I will focus on the isodoc class for application letters. I have pushed a template in my repository at Github. If you want documentation for this letter, then type Alt+F2 and in the prompt enter (without quotes) “texdoc isodoc”, or look here. The documentation for this package is really good, and contains some examples, so don’t hesitate to refer to it if you have any problem.

Basically, the .tex file is divided into three parts, that is to say the preamble, the setup of the letter and then the text. The following is a description of the parts from my template that I use for an example :

  1. A brief description of the preamble :
  2. % Created 2010-09-21 Tue 22:02
    \documentclass{isodoc}
    \usepackage{xltxtra}

    First, here is the class of the document, and then the package for XeLaTeX.

    \linespread{1.05}
    \setmainfont[Numbers=OldStyle,Ligatures=Historic]{TeX Gyre Pagella}

    Here is the usual setup for fonts I use. If you want some documentation about TeX Gyre Pagella, type Alt+F2 and enter in the prompt “texdoc qpl-info”, or look here.

    \usepackage{fixltx2e}
    \usepackage{graphicx}
    \usepackage{url}
    \usepackage{float}
    \usepackage{wrapfig}
    \usepackage{soul}
    \usepackage{textcomp}

    Some useful packages, nothing special.

    \usepackage[frenchb]{babel}

    If you are not french, replace it by polyglossia, according to the language you wish to use. For more information, type Alt+F2 and “texdoc polyglossia” in the prompt or look here.

    \usepackage{hyperref}
    \hypersetup{
    colorlinks=true, linktocpage=true,breaklinks=true,
    urlcolor=spot, linkcolor=blue, citecolor=green,
    pdftitle={Letter},%the title
    pdfauthor={}
    }

    Nothing special, just the usual hyperref setup I use.

    \tolerance=1000 % http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/LatexTips.html
    \usepackage{pdfpages}
    \definecolor{headcolor}{gray}{0.5}
    \definecolor{spot}{rgb}{0.6,0,0}
    \definecolor{headingcolor}{rgb}{0.6,0,0}

    Some nice settings, for hyphenation, and others, such as headcolor, which unable the nice gray color of headers and footers you will see in the screenshot at the bottom of my post.

  3. The following is a brief description of the setup of the letter (notice that the following is just MY setup, an example, there are more options, look at the isodoc documentation I have indicated above if you need more) :
  4. \setupdocument{%about this section, see isodoc, p. 3 to 7
    language = french
    ,
    company = Alexandre Krispin
    ,
    who = Alexandre Krispin
    ,
    street = {41 rue Guynemer}
    ,
    city = St-Denis
    ,
    zip = 93200
    ,

    Here is the first part of my setup. If you are not french, replace french by your language. Since it is not a letter from an employee of a company, I have put my name after “company =”, as it is indicated in the documentation. Then, you have to put your name and adress. Notice that you must put a comma after the information you enter, in order to indicate the end of the information. Also, if you want to put commas in your adress, you will have to use brackets {}. If you don’t use the brackets {}, then you will have erors when compiling your file.

    to = {Université Paris Ouest \\
    Nanterre La Défense\\
    200, avenue de la République\\
    92201 \caps{NANTERRE CEDEX}}
    ,
    return
    ,
    header
    ,
    date = today
    ,
    opening = {Madame, Monsieur,}
    ,
    subject = {Here goes the subject of your letter}
    ,

    “To” indicates the addressee. “Return” the address where you wish to receive an answer, etc. For more information, look at the isodoc documentation, easy to understand and very good.

    closing = {Je me tiens à votre entière disposition pour plus
    d’information, je vous prie d’agréer, Madame, Monsieur, l’expression
    de mes salutations les plus distinguées}
    ,
    signature = Alexandre Krispin
    ,
    footer
    ,
    phone = 0628766934
    ,
    email = k.m.alexandre@gmail.com
    ,
    website = \url{https://alexkrispin.wordpress.com/}
    ,
    fill
    ,
    }

    Then comes the closing, the signature and the footer if you want it. In the footer will appear your phone, email and your website.
    The fill option is to get the text fully justified, on the left and on the right. In other words, “fill” is the option to get the usual hyphenation with LaTeX.

  5. Finally, you have the environment in which your text is written :
  6. \begin{document}
    \letter{
    Je me présente, je m’appelle henri. Je voudrais bien réussir ma vie, être aimé. Quand je serai grand, j’aimerai bien être médecin, ou plombier, ou rappeur, ou dealer, ou braqueur, ou\ldots tout niquer tout dans paname !
    […]
    etc, etc.
    }
    \end{document}

Here is a screenshot of the output, a pdf file, after compiling with xelatex :

You can find the source file of this example in my repository at Github.

If you have any problem, don’t hesitate to leave a comment.

Writing an article with XeLaTeX : part 2

Writing an article is nothing special, but it might require some skills if your are not used to \LaTeX and want to use some special packages. When I was using pdflatex, one of those I was constantly using was ClassicThesis. Indeed, ClassicThesis is really an amazing package. It is based on the style of The Element of Typographic Style, written by Robert Bringhurst. If you don’t know this famous book, then look here :
The Elements of Typographic Style at amazon.com
Or
The Elements of Typographic Style at wikipedia.org
If you are also interested to this, maybe you should take a look here for an application of this book to the web typography :
The Elements of Typographic Style applied to the web

Anyway, the purpose of this post is to show you a template I have made in order to use classicthesis for an article, and to be able to compile the .tex file with XeLaTeX. To make it work, you have to do the little trick I have previously described :
Modifying the classicthesis package to make it work when compiling the *.tex file with xelatex instead of pdflatex.

Also, I have uploaded the template to my repository at Github. The following is a short description of this template.

\documentclass[10pt,a4paper]{scrartcl} % KOMA-Script article
\usepackage{xltxtra} %some packages for xelatex
\usepackage[frenchb
%arabic
%english
]{babel} %for french. If you write in english, then you might want to
%get a try to polyglossia

First I have put the basic packages to write an article which will be compiled with XeLaTeX. But notice that since I am french I use babel, but if, for example, you are indian, english, japanese, etc, then get a try to polyglossia.

%\setmainfont[Numbers=OldStyle,Ligatures=Historic]{TeX Gyre Pagella}

%If you want other fonts, try the following
%\setmainfont{Charis SIL}
%\setmainfont{URW Palladio L}
%\setmainfont{Linux Libertine O}
%\setmainfont{Gentium Book Basic}

%For japanese input :
\newfontfamily\ja[Scale=0.8]{IPA明朝}

The above shows you the setup for the fonts. If you don’t want the default font used with the ClassicThesis package, then uncomment any font you want to use instead. I have also included the setup to write in japanese, remove it if you don’t want it.

If you plan to write in japanese your entire articles, then set IPA明朝 as your main font, and if you plan to write in any other language, then set the font corresponding to your language as the main font. If you don’t know what is the font corresponding to your language, then look at the tips I have previously written here.

\usepackage{color} %If you want to use it within your text, use the
%command \textcolor{spot}{your text}
\definecolor{spot}{rgb}{0.6,0,0}
\definecolor{boxframe}{rgb}{0.6,0,0}
\definecolor{boxfill}{rgb}{1,.95,.95}

Here I have set a color, just in case I would need it.

\usepackage{hyperref}
\hypersetup{%
colorlinks=true, linktocpage=true, pdfstartpage=3, pdfstartview=FitV,%
% uncomment the following line if you want to have black links (e.g., for printing)
%colorlinks=false, linktocpage=false, pdfborder={0 0 0}, pdfstartpage=3, pdfstartview=FitV,%
breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
hypertexnames=true, pdfhighlight=/O,%hyperfootnotes=true,%nesting=true,%frenchlinks,%
urlcolor=blue, linkcolor=blue, citecolor=green, %pagecolor=RoyalBlue,%
%urlcolor=Black, linkcolor=Black, citecolor=Black, %pagecolor=Black,%
pdftitle={Article},%the title
pdfauthor={Alexandre Krispin},%your name
pdfsubject={},%
pdfkeywords={},%
pdfcreator={XeLaTeX},%
pdfproducer={A happy XeLaTeX user}%
}

Here is nothing special, the usual hyperref setup I use.

\usepackage{enumitem} %if you want to customize lists
\usepackage{array} %texdoc array
\usepackage{natbib} % an extension to allow author-year citations
% along wih numerical citations. For more
% informations, texdoc natbib
\usepackage{eukdate} %to redefine the default layout of the date format
\usepackage{textcomp} %some special characters
\usepackage{url} %for url
\usepackage{longtable} %for long tables
\usepackage{textcomp} %additional characters
\usepackage{amsmath} %for maths
\usepackage{graphicx} %to include graphics
\usepackage{wrapfig} %to get nice wrap of figures
\usepackage[nochapters]{classicthesis}
\usepackage[nochapters]{classicthesis-ldpkg}

Some useful packages. Add or remove some if you need or don’t need something. There is also the command loading the ClassicThesis package.

\title{\rmfamily\normalfont\spacedallcaps{
The so-called Iran’s threat%The title of your article
}}
\subtitle{\rmfamily\normalfont\spacedallcaps{
Facts and analysis
}}
\author{\spacedlowsmallcaps{
Alexandre Krispin %author name and first name
}}

\begin{document}

\maketitle

%\begin{abstract}

%\noident
%********************************
%The abstract of your article
%*******************************

%\end{abstract}

\tableofcontents

%\section{}

%\subsection{}

The usual opening setup, with an abstract and a table of content, nothing special.

Here are screenshots showing you how the template looks like. The first screenshot :

And the second screenshot, which show another page :

I have pushed the source file of this example to my repository at Github.

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.

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 :

Fonts with XeLaTeX : tips and troubleshooting

  • First, one thing about fonts with XeLaTeX. How do I know what fonts I could use for the language I want to typeset ? Open a terminal (with ubuntu, enter alt+f2, and enter gnome-terminal in the prompt), and copy the following :

    fc-list :lang=en

    It will give you all fonts with their style that you can use for each language you specify. If you want to specify another language, then replace the “en” after “lang=” with any other language. For example, if i want to know what are the japanese fonts I can use, I replace “en” with “ja”, it returns :

    $ fc-list :lang=ja
    YOzFontNF:style=Bold
    YOzFont:style=Regular
    YOzFontEF:style=Bold
    YOzFontCF:style=Bold
    YOzFontAF:style=Bold
    IPA X0208 P明朝,IPAX0208PMincho:style=Regular
    YOzFontN90:style=Regular
    YOzFontNF:style=Italic
    YOzFontEF90:style=Regular
    YOzFontEF:style=Italic
    YOzFontAF:style=Italic
    YOzFontCF:style=Italic
    YOzFont:style=Bold
    YOzFontE:style=Regular
    YOzFontF:style=Regular
    YOzFontA:style=Regular
    YOzFontC:style=Regular
    YOzFontN:style=Regular
    YOzFontEF90:style=Bold
    文泉驛等寬正黑,WenQuanYi Zen Hei Mono,文泉驿等宽正黑:style=中等,Medium
    文泉驛等寬微米黑,WenQuanYi Micro Hei Mono,文泉驿等宽微米黑:style=Regular
    YOzFontEF90:style=Bold Italic
    YOzFontA90:style=Italic
    IPA X0208 Pゴシック,IPAX0208PGothic:style=Regular
    YOzFont90:style=Italic
    YOzFont:style=Italic
    YOzFontC90:style=Italic
    YOzFont:style=Bold Italic
    YOzFontE90:style=Italic
    YOzFont90:style=Bold Italic
    YOzFontNF90:style=Bold
    YOzFontF90:style=Italic
    YOzFontCF90:style=Regular
    YOzFontF:style=Bold Italic
    YOzFontE:style=Bold Italic
    YOzFontNF90:style=Italic
    YOzFontC:style=Bold Italic
    YOzFontA:style=Bold Italic
    YOzFontN:style=Bold Italic
    さざなみ明朝,Sazanami Mincho:style=Regular,Mincho-Regular
    YOzFontEF:style=Bold Italic
    YOzFontAF:style=Bold Italic
    YOzFontCF:style=Bold Italic
    YOzFontNF:style=Bold Italic
    Takao P明朝,TakaoPMincho:style=Regular
    文泉驛正黑,WenQuanYi Zen Hei,文泉驿正黑:style=中等,Medium
    YOzFontN90:style=Italic
    IPAexゴシック,IPAexGothic:style=Regular
    YOzFontEF90:style=Italic
    YOzFontCF90:style=Bold Italic
    東風ゴシック,Kochi Gothic:style=標準,Regular
    YOzFontNF:style=Regular
    YOzFontAF:style=Regular
    YOzFontCF:style=Regular
    YOzFontEF:style=Regular
    東風明朝,Kochi Mincho:style=標準,Regular
    IPA X0208 UIゴシック,IPAX0208UIGothic:style=Regular
    YOzFontAF90:style=Regular
    Takaoゴシック,TakaoGothic:style=Regular
    YOzFont90:style=Regular
    IPA X0208 明朝,IPAX0208Mincho:style=Regular
    YOzFontAF90:style=Bold
    YOzFontN90:style=Bold
    IPAゴシック,IPAGothic:style=Regular
    YOzFontCF90:style=Italic
    YOzFontN90:style=Bold Italic
    YOzFontAF90:style=Bold Italic
    文泉驛微米黑,WenQuanYi Micro Hei,文泉驿微米黑:style=Regular
    YOzFontA90:style=Bold Italic
    IPA Pゴシック,IPAPGothic:style=Regular
    YOzFontC90:style=Bold
    YOzFontC90:style=Bold Italic
    YOzFontA90:style=Bold
    IPA X0208 ゴシック,IPAX0208Gothic:style=Regular
    YOzFontE90:style=Bold Italic
    YOzFontF90:style=Bold
    YOzFontNF90:style=Bold Italic
    YOzFontF90:style=Bold Italic
    Takao Pゴシック,TakaoPGothic:style=Regular
    YOzFontE90:style=Bold
    TakaoExゴシック,TakaoExGothic:style=Regular
    YOzFont90:style=Bold
    YOzFontC90:style=Regular
    YOzFontCF90:style=Bold
    YOzFontA90:style=Regular
    YOzFontF:style=Italic
    YOzFontN:style=Bold
    YOzFontE:style=Italic
    YOzFontC:style=Italic
    YOzFontA:style=Italic
    YOzFontN:style=Italic
    YOzFontF:style=Bold
    YOzFontE:style=Bold
    YOzFontC:style=Bold
    YOzFontA:style=Bold
    IPAex明朝,IPAexMincho:style=Regular
    IPA明朝,IPAMincho:style=Regular
    TakaoEx明朝,TakaoExMincho:style=Regular
    Takao明朝,TakaoMincho:style=Regular
    YOzFontF90:style=Regular
    YOzFontAF90:style=Italic
    YOzFontNF90:style=Regular
    IPA P明朝,IPAPMincho:style=Regular
    YOzFontE90:style=Regular

    If you don’t know how you could know what is the abbreviation for your language, then copy the following line in your terminal :

    ls /usr/share/locale

    It will return all locales :

    The locales show you the abbreviation for each language, which you can use with the “fc-list :lang=*” command. For example, if I want to know the fonts for arabic :

    fc-list :lang=ar
    Times New Roman:style=Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
    Nazli:style=Bold
    Scheherazade:style=Regular
    PakType Naqsh:style=Regular
    FreeSerifb:style=Regular
    Times New Roman:style=Negreta,tučné,fed,Fett,Έντονα,Bold,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiona,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
    FreeSerif:style=Mittel,µεσαία,Medium,Normal,Gemiddeld,navadno
    Courier New:style=Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
    PakType Tehreer:style=Regular
    KacstOne:style=Medium
    MPH 2B ダマセ,MPH 2B Damase,MPH 2B 大媽賊,MPH 2B 다마세,MPH 2B 大妈贼:style=Regular
    Arial:style=Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
    DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
    Homa:style=Regular
    DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
    Courier New:style=Negreta,tučné,fed,Fett,Έντονα,Bold,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
    RupeeTechFat:style=Regular
    DejaVu Sans:style=Bold
    DejaVu Sans:style=Book
    Arial:style=Negreta,tučné,fed,Fett,Έντονα,Bold,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
    Titr:style=Bold
    Nazli:style=Regular
    DejaVu Sans Mono:style=Book
    DejaVu Sans Mono:style=Bold

  • Secondly, if you use XeLaTeX for the first time with, let say, Ubuntu 10.04, you are likely to get a problem with your fonts. Indeed, with Ubuntu 10.04 I got error messages when I wanted to use TeX Gyre Pagella. Here is a post to show you how to solve this problem if you get it. Notice that if you have installed TeXlive with your package manager, maybe you won’t get this problem, I don’t know.

    Unfortunately, I am not aware of how XeLaTeX behaves with Microsoft Windows XP, Vista or Seven. For this reason, if you use those operating system, I can try to help you if you post a comment, but I can’t ensure you I can sucessfully help you. If you use a Unix system, then the following method might work, and has been tested with Ubuntu 10.04.

    First, you need to copy texlive-fontconfig.conf in an other part of your system. For this, you need administrator privileges. To do so, you have two ways.

    1. The first way, faster, depends on how you have installed your TeX distribution. If you have installed TeXlive with your package manager (Synaptic or Ubuntu software center in Ubuntu), then copy the following line in a terminal (to run this application, alt+f2 and enter gnome-terminal in the prompt) :
    2. sudo cp /usr/share/texmf-texlive/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf

      Since I don’t have installed TeXlive with my package manager, this line may not be correct. If so, don’t hesitate to leave a comment, I can modify it and tell you how to find the right line by yourself. Otherwise, if you are not familiar with the command line, then use your file manager. For this, type Alt+F2, and in the prompt enter gksu nautilus. Here is a screenshot :

      Then, look at the device section in the panel on your left, and go in the file system section :


      Then, search for the right directory in usr, share, something like texmf-texlive (since I can’t try I am not sure), fonts, conf, and copy texlive-fontconfig.conf. Then return select once again the file system directory, go in etc, fonts, conf.d, past the file in this directory and rename it as 09-texlive.conf. Then run the following line in a terminal :

      sudo fc-cache -fsv

    3. If you have installed TeXlive with the install script install-tl, then copy the following line in your terminal :

      sudo cp /usr/local/texlive/2010/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf

      And this one :

      sudo fc-cache -fsv

    For more details, see the texlive guide, section 3.4.5, p. 14. To do so, type alt+F2, enter texdoc texlive-en in the prompt. Or look here.

writing an article with XeLaTeX : part 1

Writing an article with LaTeX and compiling it with pdflatex might be a good solution if you don’t expect to use japanese, chinese, arabic characters or anything else which is not included in the roman alphabet. But if you plan, for example, to write in japanese, then pdflatex is not the better way. Moreover, the documentation on the web about CJK, LaTeX and japanese is generally outdated. See for example the japanese documentation for LaTeX in the japanese wiki of Ubuntu. In the outlook section of LaTeX packages, it is even recommended to install pTeX, based on TeTeX.

Nowadays, we don’t have to use LaTeX anymore, we can use XeLaTeX. Compiling a *.tex file with XeLaTeX can be done with TeXLive 2009 or TeXLive 2010, so you don’t have to update your TeX distribution if you use Ubuntu 10.04 or any other operating system with a recent TeX distribution. I have made a template to be compiled with XeLaTeX, based on classicthesis.sty, mathspec.tex and many other informations I found on the web. Here is a brief description of the template I have pushed to my repository at Github :

\documentclass[
paper=a4,
fontsize=10pt,
%DIV=calc,
headsepline,
%footsepline, %to get a line separating footnote from page number.
%titlepage=true, %if you want an entire page for you title, name and date.
headings=normal,
version=last,
%twoside=true, %if you want to print on both side (recto-verso) of the %page.
%headinclude=true,
footinclude=true,
mpinclude=true,
%BCOR=0mm,
fleqn
]{scrartcl}

The above code show you scrartcl with some options, depended of what you want, you can comment, uncomment or add others. If you need documentation about the class scrartcl, and if you use Ubuntu with gnome, type alt+F2 and in the prompt enter texdoc scrguien. If you don’t use Ubuntu, and you don’t know where are the files related to Koma-script, you can download it at ctan.org

.

\usepackage{xltxtra} %include fontspec, xunicode, etc. For more %details, texdoc xltxtra
%\usepackage{mathspec}
%\usepackage{polyglossia} %xetex version of the babel %package. Since it is incomplete, %french users have to use babel. For %other users, replace french by your language
%\setmainlanguage{french}
%\setmainlanguage[variant=british]{english} %for english users. For
%more documentation, texdoc polyglossia.
%\usepackage{xspace}
\usepackage[frenchb
%arabic
%english
]{babel}

The above are the package xltxtra which load other packages to be used with xelatex. Also, since I need the french localization, I load frenchb with babel, but if you are english, german, etc, you just have to comment frenchb and uncomment or add other one. More details about it with texdoc babel, or at ctan. Notice that you could use polyglossia, the replacement of babel made for XeTeX. Unfortunately, the french option for polyglossia is not as good as the one for babel, that’s why I use babel with XeLaTeX. But if you are not french, you should try polyglossia.


%**********************************************************
%Comment or uncomment to select one of the following fonts
%**********************************************************
%\setmainfont{Charis SIL}
%\setmainfont{URW Palladio L}
%\setmainfont{Linux Libertine O}
%\setmainfont{Gentium Book Basic}
%\usepackage{fourier}
%\setmainfont{Utopia-Regular}
% \usepackage[scaled=0.85]{berasans}
% \usepackage[scaled=0.85]{beramono}
%\usepackage[sc]{mathpazo}
\linespread{1.05}
\setmainfont[Numbers=OldStyle,Ligatures=Historic]{TeX Gyre Pagella}

Here are some examples of fonts commented. TeX Gyre Pagella is uncommented since it is the font I use by default for my articles.


%***********************************************************
%For japanese input \newfontfamily\ja[Scale=0.8]{IPA明朝} %If you wish to write in
%japanese, then use the command
%\jap. Here is an example : “Hello, here is a test : {\ja ここはテストしてま〜〜〜す!}.” Try to compile it. %***********************************************************
%If you want to write in arabic from the right to the left load the %following package :
%\usepackage{bidi} %then, use the command \setRL to right from the right to the left. For more details, texdoc bidi.

Here are the settings for japanese, and an example. Also, notice that you can write your texts from the right to the left with the package bidi.


%Other useful packages for a basic article
\usepackage{url} %for url
\usepackage{longtable} %for long tables
\usepackage{textcomp} %additional characters
\usepackage{amsmath} %for maths
\usepackage{graphicx} %to include graphics
\usepackage{wrapfig} %to get nice wrap of figures
\usepackage{eukdate} %to redefine the default layout of the date format
% ********************************************************************
% Hyperreferences setup
%*******************************************************
\usepackage{hyperref}
\hypersetup{% colorlinks=true, linktocpage=true, pdfstartpage=3, pdfstartview=FitV,%
% uncomment the following line if you want to have black links (e.g., for printing)
%colorlinks=false, linktocpage=false, pdfborder={0 0 0}, pdfstartpage=3, pdfstartview=FitV,
% breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,
% plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,
% hypertexnames=true, pdfhighlight=/O,
%hyperfootnotes=true,%nesting=true,
%frenchlinks,%
urlcolor=blue, linkcolor=blue, citecolor=green,
%pagecolor=RoyalBlue,% %urlcolor=Black, linkcolor=Black, citecolor=Black,
%pagecolor=Black,% pdftitle={Article},%the title pdfauthor={Alexandre Krispin},%your name pdfsubject={},% pdfkeywords={},% pdfcreator={XeLaTeX},% pdfproducer={A happy XeLaTeX user}% }

Here is nothing special, just some packages that can be useful, and the hyperref setup.


%**********************************************************
%Appearance, etc
%*********************************************************
\usepackage{xcolor} %use color with the command \textcolor{spot}{some text to
%with your color previously defined}

%redefining the section command in order to get previously defined
%color for each section title.
% \makeatletter
% \renewcommand\section{\@startsection {section}{1}{\z@}%
% {-3.5ex \@plus -1ex \@minus -.2ex}%
% {2.3ex \@plus.2ex}%
% {\color{spot}\normalfont\Large\bfseries}}
% \makeatother

%\usepackage[left=4cm,right=4cm,top=3cm,bottom=3cm,includeheadfoot]{geometry}
\areaset[5mm]{312pt}{761pt} % 686 (factor 2.2) + 33 head + 42 head \the\footskip
\setlength{\marginparwidth}{7em}%
\setlength{\marginparsep}{2em}%

\usepackage[automark]{scrpage2}
%\pagestyle{scrheadings} %for more information about headings, texdoc scrguien,
%chp. 4

Here is the setup for the margins, etc. You will notice that I tried to set a color for the sections, but haven’t been able to get it successufly working. And since I don’t really care about it, I have given up.


%**************************************************************************************
% for the following, see mathspec.tex (for me /usr/local/texlive/2010/texmf-dist/xelatex/mathspec/mathspec.tex
% for ubuntu users who have install texlive with the package manager, replace /usr/local/texlive/2010 by /usr/share/texmf-texlive (but I’m not sure, you have to check your directory /usr/share)
\definecolor{spot}{rgb}{0.6,0,0}
\definecolor{boxframe}{rgb}{0.6,0,0}
\definecolor{boxfill}{rgb}{1,.95,.95}

\makeatletter
\setlogokern{eT}{-0.074em}
\setlogokern{Xe}{-0.063em}
\setlogokern{eL}{-0.068em}
\setlogokern{La}{-0.305em}
\setlogokern{aT}{-0.07313em}
\setlogokern{X2}{0.101em}
\setlogodrop{0.131em}
\setLaTeXa{%
\ifdim\fontdimen\@ne\font=\z@\else
\addfontfeature{FakeSlant=\the\fontdimen\@ne\font}%
\fi
\if b\expandafter\@car\f@series\@nil
\check@mathfonts\fontsize\sf@size\z@
\math@fontsfalse\selectfont A%
\else
\scshape a%
\fi}
\setLaTeXee{\mbox{$\epsilon$}}
\seteverylogo{%
\if b\expandafter\@car\f@series\@nil%
\setlogokern{Te}{-0.075em}%
\setlogokern{eX}{-0.068em}%
\else
\setlogokern{Te}{-0.084em}%
\setlogokern{eX}{-0.063em}%
\fi}
\newcommand\tablerowa[3]{$\csname #1#3\endcsname$ & \cmd{#1#3} & $\csname #2#3\endcsname$ & \MakeLowercase{\cmd{#2#3}}}
\newcommand\tablerowb[1]{$\csname #1\endcsname$ & $\csname var#1\endcsname$ & \cmd{var#1}}
\def\topbottomrule{\noalign{\ifnum0=`}\fi
\@aboverulesep=\aboverulesep
\global\@belowrulesep=\belowrulesep
\global\@thisruleclass=\@ne
\@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
\renewcommand{\topfraction}{.75}
\renewcommand{\bottomfraction}{.75}
\renewcommand{\textfraction}{.25}
\renewcommand{\floatpagefraction}{.75}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
\def\fps@figure{htb!}
\g@addto@macro\table{\collecttable}
\newlength\captionwidth
\newlength\mincaptionwidth
\setlength\mincaptionwidth{50mm}
\long\def\collecttable#1\caption#2{%
\toks@{#1}%
\sbox\z@{\ignorespaces\the\toks@\unskip}%
\setlength\captionwidth{\wd\z@}%
\ifdim\captionwidth \captionwidth
\centerline{\parbox[t]{\captionwidth}{\formatcaption#1:#2\@nil}}%
\else
\global\@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\newenvironment{advanced}
{\begin{minipage}[t]{\textwidth}\begin{description}\item[\rmfamily\mdseries\scshape\footnotesize\spotcolor advanced]\itshape\footnotesize}
{\end{description}\end{minipage}}
\makeatother

The above code show you the definition of the color “spot” and other settings. Since it is just a copy of settings found in mathspec.tex, you can look at your xelatex directory of your TeX distribution. For me it is at /usr/local/texlive/2010/texmf-dist/doc/xelatex/mathspec/mathspec.tex. If you don’t find where is your directory, take a look at ctan.


\usepackage{placeins}
\usepackage{titlesec}
\usepackage{booktabs} % for better rules in tables
\usepackage{textcase} % for \MakeTextUppercase
% sections \FloatBarrier
\titleformat{\section} {\relax}{\textsc{\MakeTextLowercase{\thesection}}}{1em}{\large\scshape\lowercase}
% subsections
\titleformat{\subsection} {\relax}{\textsc{\MakeTextLowercase{\thesubsection}}}{1em}{\normalsize\rmfamily\mdseries\itshape\lowercase}

% subsubsections
\titleformat{\subsubsection} {\relax}{\textsc{\MakeTextLowercase{\thesubsubsection}}}{1em}{\normalsize\rmfamily\mdseries\itshape\lowercase}

% paragraphs
\titleformat{\paragraph}[runin]
{\normalfont\normalsize}{\theparagraph}{0pt}{\scshape}

% descriptionlabels
\renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}\scshape{#1}}

% spacedlowsmallcaps textit textsc
% spacing
{\relax}%
{\titlespacing*{\chapter}{0pt}{1\baselineskip}{1.2\baselineskip}}
\titlespacing*{\section}{0pt}{1.25\baselineskip}{1\baselineskip}
\titlespacing*{\subsection}{0pt}{1.25\baselineskip}{1\baselineskip}
\titlespacing*{\paragraph}{0pt}{1\baselineskip}{1\baselineskip}

Here is some code I have taken from the classicthesis package. This code modify the layout of sections, subsections, subsubsections, paragraphs and of text in \items[]. If you want to look at the original file, classicthesis.sty, you can find it in directory */texmf-dist/tex/latex/classicthesis/, where * could be /usr/share, or /usr/local/texlive/2010, depending on the installation way you have chosen to install TeXlive. Otherwise, take a look at ctan.org

.

p, li { white-space: pre-wrap; }

%*********************************************************

%Table of content

%*******************************************************

\usepackage{multicol} %useful here to get a table of contents with 2 columns

\addtokomafont{sectionentry}{\rmfamily\mdseries\scshape\lowercase}

\addtokomafont{section}{\rmfamily\mdseries\scshape\lowercase}

\addtokomafont{subsection}{\rmfamily\mdseries\itshape}

%If you don’t want to make subsubsections appear in your table of contents

\setcounter{tocdepth}{2}

\makeatletter

\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname the#1\endcsname\hspace{\marglistsep}}}

\makeatother

%hypersetup{linkcolor=black,urlcolor=black}

%*************************************************

%if you want to get dot between the word and the page number in the

%table of contents, uncomment the lines between \makeatletter and \makeatother.

% \makeatletter

% \renewcommand\l@section[2]{%

% \ifnum \c@tocdepth >\z@

% \addpenalty\@secpenalty

% \addvspace{1.0em \@plus\p@}%

% \setlength\@tempdima{1.5em}%

% \begingroup

% \parindent \z@ \rightskip \@pnumwidth

% \parfillskip -\@pnumwidth

% \leavevmode {\bfseries

% \advance\leftskip\@tempdima

% \hskip -\leftskip

% #1}\nobreak\

% \leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}

% \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par

% \endgroup

% \fi}

% \makeatother

%**********************************************************

I have taken the code for the table of content from mathspec.tex, so once again if you like it look at this file in the directory previously indicated. I have added the package multicol in order to get the same layout than the one you can see in mathspec.pdf. Also, though I don’t like it, you can uncomment the lines between makealetter and makeatother if you want to get dots between the name of your titles and the page number.


\begin{document}
%\frenchspacing

\begin{titlepage}

\title{
\rmfamily
\mdseries
\lowercase{
\scshape{
\textcolor{spot}{
%Here goes your title
}}}}

\subtitle{
\rmfamily
\mdseries
\itshape
\normalsize{
%Enter here your subtitle
}}
\author{
%Enter your name and first name
}

\end{titlepage}

\maketitle

%\addtocontents{toc}{\protect\begin{multicols}{2}} %if you want to get a table of
% contents with 2 columns. If you prefer one column, comment this line and
% the one just before \end{document}
\tableofcontents

%*******************************************************************
%
% your text goes here
%
%******************************************************************

%\addtocontents{toc}{\protect\end{multicols}}
\end{document}

The settings for the title is similar to those of mathspec.tex, but since in mathspec.tex a different document class is used, I have changed some settings to make it work with the koma-script class, scrartcl.

Also, if you want a table of contents divided in two columns, then uncomment the line “\addtocontents{toc}{\protect\begin{multicols}{2}}”, and the other just before \end{document}, “\addtocontents{toc}{\protect\end{multicols}}”.

Lastly, if you want to use the color spot previously defined, write \textcolor{spot}{the text you want to colorize} and you will get it. Here are 2 screenshots showing how this template looks with an example of short article :

And the other picture :

You can find this example at the same directory of my repository, here.

%d bloggers like this: