[Tex/LaTex] Swapping from pdfLaTeX to XeLaTex

pdftexxetex

This forum has always been a great source of quick and sophisticated help. So I hope you can show me how it's done once again!

I will soon have to write my final thesis at university and up until now I managed to get along with pdfLaTeX quite well and I grew very fond of it. But now the problems I cannot seem to resolve start to pile up, mostly due to different languages I have to use in one text. So everybody keeps suggesting that I should change to XeLaTeX because it handles different fonts/languages better. On the other hand I have an extensive preamble (mostly because I need a quite 'special' kind of bibliography) and I cannot find out which packages are compatible with XeLaTeX and which are not or if there are better options.

I have already read the thread Moving from pdfLaTeX to XeTeX – what do I need to know? and Using XeLaTeX instead of pdfLaTeX but they don't cover everything I need…

%Preamble%

\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}

\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{caption}
\usepackage{filecontents}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{yfonts}
\usepackage{hyperref}
\usepackage{pdfpages}
%\usepackage{showframe}
\usepackage{lipsum}

%%Tables%%
\usepackage{array,booktabs,xcolor,colortbl}
\usepackage{multirow}
\usepackage{diagbox}
\newcommand{\specialcell}[2][c]{%
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

%%Encoding%%
\usepackage{lmodern}
\usepackage[footnote,printonlyused]{acronym}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{tipa}
\usepackage{csquotes}
\usepackage{combelow}

%%Footnotes%%
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
\setkomafont{disposition}{\mdseries\rmfamily}
\onehalfspacing
\captionsetup[table]{skip=5pt,font=footnotesize}
\deffootnote[1.0em]{1.0em}{1.0em}
    {\textsuperscript{\thefootnotemark}\,\enskip}
\renewcommand{\baselinestretch}{1.5}

%%Inhaltverzeichnis%%
\usepackage{tocstyle}
\usetocstyle{allwithdot}

%%Bibliography%%
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}
\addbibresource{Bibliography.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{%
  \iffieldundef{\thefield{datelabelsource}year}%
    {}{%
       \printtext[parens]{%
         \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
         \iffieldsequal{year}{\thefield{datelabelsource}year}%
           {\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
       }%
      }%
}
\renewcommand*{\bibpagespunct}{\addcomma\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
   {}{%
      \printnames[byeditor]{editor}%
      \setunit{\addspace}%
      \usebibmacro{byeditor+othersstrg}%
      \clearname{editor}\newunit%
   }%
   \usebibmacro{byeditorx}%
   \usebibmacro{bytranslator+others}%
}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{%
  \iffieldundef{#1type}{\bibstring{#2}}{%
    \ifbibxstring{\thefield{#1type}}%
      {\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}%
  }%
}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

\renewcommand*{\labelnamepunct}{\addcolon\space}
\newcounter{SprachB}
\newcommand{\SprachB}[1]{\refstepcounter{SprachB}\label{#1}}

\usepackage{etoolbox}
\AtBeginEnvironment{quote}{\singlespacing\footnotesize}

\DeclareRobustCommand{\cyrins}[1]{
    \begingroup\fontencoding{T2A}%
    \begingroup\fontfamily{cmr}%
    \foreignlanguage{russian}{#1}%
    \endgroup\endgroup
  }

\hyphenation{Script-Oralia}

%Document%

\begin{document}

\pagenumbering{arabic}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage\hspace{.5cm}}
\setcounter{page}{3}

\begin{spacing}{1.3}

\lipsum

\end{spacing}

\end{document}

All in all I want to be able to use:

  • mostly German in the main text
  • Romanian because that's the language I'm studying (special characters needed!)
  • other unproblematic european languages like English, French and Portuguese
  • IPA-symbols since the thesis is about phonology
  • Cyrillic characters that can be found on a standard keyboard today
  • old Cyrillic (and Glagolitic) characters
  • Japanese characters (Hiragana, Katakana and Kanji)

I really hope this is not too big a problem because my thesis on writing and phonology will be hard to manage without the list above.

Of course, if you can think of a way to do all that in pdfLaTeX then I'd be happy to try it as well.

Two final pieces of information: I'm using the TexMaker (but I could move to another compiler if that makes anything easier) and OpenSuse is my OS (so I'm not sure if all extensions are available for me to download)

Thank you so much in advance!!

Best Answer

I'm trying my best to answer concerning your points:

  • mostly German in the main text

    You can achieve this using pdfLaTeX, XeLaTeX and LuaLaTeX in similar quality. Keep in mind that for a German thesis you can use babel with the ngerman option or polyglossia (not with pdflatex) with its german language.

  • Romanian because that's the language I'm studying (special characters needed!)

    It's no problem to use any UTF-8 characters (with accents etc.) in Xe-/LuaLaTeX. Only important note: Your font has to support it. If you choose a font without the characters the engine decision won't help.

  • other unproblematic european languages like English, French and Portuguese

    Those languages are supported by babel and polyglossia. You may want to read the manuals to decide which way of switching the languages is more to your liking.

  • IPA-symbols since the thesis is about phonology

    You can use the methods described in How to use phonetic IPA characters in LaTeX. That would work with pdflatex and Xe-/LuaLaTeX. In my opinion (only personal) the unicode input seems more comfortable, but that's a matter of preference.

  • Cyrillic characters that can be found on a standard keyboard today

    I don't know which characters you do want to use. But in general you can use the options from Cyrillic in (La)TeX. If I had to switch between many languages with different symbols, I would definitely go with Xe-/LuaLaTeX here.

  • old Cyrillic (and Glagolitic) characters

    This seems to be a perfect task for Xe-/LuaLaTeX. Just input the characters in UTF-8 and search for a font which maps it to the correct "old characters".

  • Japanese characters (Hiragana, Katakana and Kanji)

    As I recommended Xe-/LuaLaTeX before for font switching, you should read this answer. Personally I have very good experiences with luatexja-fontspec.


Recommendation: I would, after considering your points, go with Xe-/LuaLaTeX. Now you'd have to decide which one you'd like to use. I've used XeLaTeX for a while, but am now a LuaLaTeX user, as on my machine I do not have those large speed differences (on big documents).

As I'm a microtype user and as I manipulate input to fit my needs (e.g. transform every z.B. into z.\,B.) I use LuaLaTeX for bigger projects. If you do not need those manipulations, XeLaTeX will suffice.


Concerning your source code (given you switch to Xe-/LuaLaTeX):

  • remove inputenc (encoding is UTF-8 eitherway) and fontenc (unsupported concept)
  • replace lmodern with a respective fontspec call
  • update your \cyrins command to swith font and not encoding
  • (optional) replace fancyhdr with the KOMA native scrlayer-scrpage

Btw: replace means you should read the documentation and use the way given there.


Update: I've modified your code a bit to serve as starter for the transition to XeLaTeX.

In the last edit I removed the dependency on Arial and make use of the Libertinus Serif font which is included in TeX Live.

\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}

\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{scrlayer-scrpage} % instead of fancyhdr

\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}
\newfontfamily\russianfont{Libertinus Serif}
\newfontfamily\ipafont{DoulosSIL-R.ttf}

\usepackage{polyglossia}
\setdefaultlanguage{german}
\setotherlanguages{russian,romanian}
\usepackage[style=german]{csquotes}

\usepackage{yfonts}
\usepackage{tipa}
% \usepackage{combelow} don't know whether it's compatible

\usepackage{setspace}
\usepackage{filecontents}

\usepackage{graphicx}
\usepackage{caption}
\captionsetup[table]{skip=5pt,font=footnotesize}

%%Tables%%
\usepackage{array}
\usepackage{booktabs}
\usepackage[table]{xcolor} % loads colortbl
\usepackage{multirow}
\usepackage{diagbox}
\newcommand{\specialcell}[2][c]{%
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

\usepackage{lipsum}

\usepackage{pdfpages}
\usepackage{hyperref}

\usepackage[footnote,printonlyused]{acronym}
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
\deffootnote[1.0em]{1.0em}{1.0em}
    {\textsuperscript{\thefootnotemark}\,\enskip}

\setkomafont{disposition}{\mdseries\rmfamily}
\onehalfspacing
\renewcommand{\baselinestretch}{1.5}

\usepackage{tocbasic}
\KOMAoptions{toc=sectionentrydotfill} % replaces the experimental tocstyle (if you do not need dots for parts)
%\usepackage{tocstyle}
%\usetocstyle{allwithdot}

%%Bibliography%%
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}
\addbibresource{Bibliography.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{%
  \iffieldundef{\thefield{datelabelsource}year}%
    {}{%
       \printtext[parens]{%
         \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
         \iffieldsequal{year}{\thefield{datelabelsource}year}%
           {\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
       }%
      }%
}
\renewcommand*{\bibpagespunct}{\addcomma\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
   {}{%
      \printnames[byeditor]{editor}%
      \setunit{\addspace}%
      \usebibmacro{byeditor+othersstrg}%
      \clearname{editor}\newunit%
   }%
   \usebibmacro{byeditorx}%
   \usebibmacro{bytranslator+others}%
}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{%
  \iffieldundef{#1type}{\bibstring{#2}}{%
    \ifbibxstring{\thefield{#1type}}%
      {\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}%
  }%
}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

\renewcommand*{\labelnamepunct}{\addcolon\space}
\newcounter{SprachB}
\newcommand{\SprachB}[1]{\refstepcounter{SprachB}\label{#1}}

\usepackage{etoolbox}
\AtBeginEnvironment{quote}{\singlespacing\footnotesize}

\DeclareRobustCommand{\cyrins}[1]{
    {\russianfont\textrussian{#1}}%
  }

\hyphenation{Script-Oralia}

\pagenumbering{arabic}
\pagestyle{scrheadings}
\cfoot{}
\ofoot{\pagemark}

\begin{document}
\setcounter{page}{3}
\begin{spacing}{1.3}

\lipsum

\cyrins{Лорем ипсум долор сит амет, меи ид бонорум инцоррупте диссентиас, пер еа елигенди тациматес ехпетендис. Регионе торяуатос ассуеверит ад еос. Яуем прима интеллегебат еос ат. Синт молестиае интерессет ут нам, сеа цу саепе лаборес патриояуе.}

IPA: {\ipafont [ɪtsɹilijizitutaɪp]}

\end{spacing}

\end{document}