# Translating LaTeX document to XeLaTeX or LuaLaTeX

I'm writing a Thesis on the ''use of history to teach mathematics''. The first four chapters are already typed and compiled in pdfTex, I used the memoir document class.

Recently I read this Lua post and it really caught my attention.

In order to finish the Thesis process (writing and compiling the three final chapters, also have to add graphs, tables and so) I am evaluating to move to XeLaTex (I'm not sure if LuaLaTeX would be an option but it excited me what I read). I know my LaTeX, and I feel confortable with LaTeX (pdfTeX) but I also want to "see other options".

My question is: If I want to "port" the current document code and finish the three last chapters using XeLaTeX (or LuaLaTeX), What I need to achieve that successfully?

NOTE

Here I add a MWE of the ''preamble'' and the estructure.tex in order to you see the package I am using currently and you can tell if is feasible to translate the current document.

Preamble

\documentclass[12pt,letterpaper,oneside]{memoir}
\settypeblocksize{279.4mm}{215.9mm}{*}
\setulmarginsandblock{3cm}{3cm}{*}
\setlrmarginsandblock{3.9cm}{2cm}{*}
\checkandfixthelayout
\parskip=0.25cm
\usepackage{apacite}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{XCharter}
\DisemulatePackage{setspace}
\usepackage{setspace}

\usepackage{titlesec}

\titleformat*{\section}{\centering\LARGE\bfseries}
\titleformat*{\subsection}{\large\bfseries}
\titleformat*{\subsubsection}{\large\bfseries}
\input{structure.tex}


Here is the structure.tex file.

\usepackage[round]{natbib}\citeindextrue
\usepackage{graphicx} % Required to include images
\graphicspath{{./Figures/}}
\usepackage{color} % Required for custom colors
\usepackage{amsmath,amssymb,theorem} % Math packages
\usepackage{listings} % Required for including snippets of code
\usepackage{booktabs} % Required for better horizontal rules in tables
\usepackage{xspace} %
\usepackage[printonlyused,withpage]{acronym} % Include a list of acronyms
\usepackage{rotating} % Allows tables and figures to be rotated
\usepackage{microtype} % Slightly tweak font spacing for aesthetics

\makeatletter
\renewcommand{\fnum@figure}{\textsc{\figurename~\thefigure}} % Make the "Figure 1.1" text in small caps
\makeatother

• What do you mean by “port” to LuaTeX (which I prefer to XeTeX)? There is a question here that shows what packages work only on some of those engines. You just need to change them. For instance you could (although it's not absolutely necessary): inputenc to luainputenc; fontenc deleted; load XCharter through OpenType via fontspec; use polyglossia instead of babel; etc. What more are you looking for? I mean, there's not too much to do… – Manuel Aug 24 '14 at 23:33
• Let me add that XeTeX supposes documents are in UTF8 encoding, hence no inputenc has to be loaded. – Bernard Aug 25 '14 at 0:13
• You should note that microtype is only partially supported by the newer engines. LuaTeX supports most of it, as I understand it, and XeTeX supports some of it but a bit less than LuaTeX. But there are some features which you need pdfTeX for. (See the manual or search here for details.) – cfr Aug 25 '14 at 1:31
• Well the first time you asked for this you have a confusion and you wanted to translate your thesis to conTeXt and you have not a clear idea about xetex, luatex and their versions for LaTeX: xelatex and lualatex. I see that you have a better idea now, but the question still remains _why would you want or need to compile this thesis with XeLaTeX or LuaLaTeX instead of pdflatex if you're fine with that so far? – Aradnix Aug 25 '14 at 5:12
• @Aradnix The main reason: personal fullfilment. I want to "grow" in another LaTeX dimension. It is like when you have achieve one goal and then set a new one, a higher one. You learned a language and then you want to learn a new one. That is. – Mauramz Aug 25 '14 at 9:41

Well, according to what you have explained, what you need is not really translate, simply adapt your code to use XeLaTeX instead of pdflatex that is according to what I see, most affordable and easy to do.

Remember that the charm of XeLaTeX resides in to use true type fonts and especially open type easily in LaTeX. So you can bring together the best of both worlds in one document.

According to the code of your MWE:

\documentclass[12pt,letterpaper,oneside]{memoir}
\settypeblocksize{279.4mm}{215.9mm}{*}
\setulmarginsandblock{3cm}{3cm}{*}
\setlrmarginsandblock{3.9cm}{2cm}{*}
\checkandfixthelayout
\parskip=0.25cm
\usepackage{apacite}

\usepackage{fontspec} % font selection for XeLaTeX;
\defaultfontfeatures{Mapping=tex-text}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Warnock Pro}
\setmonofont{Consolas}

\usepackage[spanish]{babel}
%\usepackage{XCharter}
\DisemulatePackage{setspace}
\usepackage{setspace}

\usepackage{titlesec}

\titleformat*{\section}{\centering\LARGE\bfseries}
\titleformat*{\subsection}{\large\bfseries}
\titleformat*{\subsubsection}{\large\bfseries}
\input{structure.tex}


I replaced only the line \usepackage[utf8]{inputenc} from your preamble and instead I added these lines:

\usepackage{fontspec} % font selection for XeLaTeX;
\defaultfontfeatures{Mapping=tex-text}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Warnock Pro}
\setmonofont{Consolas}


Where I add 3 lines for use different fonts in the case you want to use different typefaces for the serif fonts (main font), another for sans serif fonts and one more if you need to use monospaced fonts. I deactivate the XCharter package. Because you don't need it in this scheme (I think).

The trick with XeLaTeX is you have installed the fonts you intend to use and invoke them properly in your preamble. If you do not write name correctly, you'll have errors. There are many more options to specify the weight and shape of the characters.

But with this you can begin. If you're using math might have to add pi font for your equations are composed correctly. I have not reached that stage, is still pending as part of the challenge.

I also have not migrated from babel to polyglossia, that's another task you will, but if I have not forgotten anything, this is a good starting point.

Don't forget to compile, when you make these changes, using XeLaTeX and not pdflatex to avoid errors.

• Apart from what you said, I would like to note that (in general) there is no clear reason to use XeLaTeX over LuaTeX, and the later seems to be a better choice looking at the future. – Manuel Aug 26 '14 at 20:01
• @Manuel Maybe I'm wrong, but far as I know, LuaTeX is still not entirely stable while XeLaTeX has already been established and there are many manuals that already include it. I know that LuaTeX has been developed with a view to be the natural successor to pdLaTeX in the future, plain and simple I had not time to try it yet. – Aradnix Aug 26 '14 at 20:28
• True, but I mean that for most people there is no advantage or disadvantage, and by using LuaTeX (I think) one helps its expansion. – Manuel Aug 26 '14 at 21:09
• @Manuel, speed would be a great reason to prefer XeLaTeX over LuaLaTeX: on one 4-page document compilation took 2.2 and 14.4 seconds respectively. – Victor Klos Oct 30 '15 at 12:54
• @VictorKlos That's quite a lot, may be that's just one example. It might be slower but usually not that slower. In any case, e.g., after X minutes/hours writing Y pages, compiling in 10 seconds or in two seconds is not really a problem for the usual user. – Manuel Oct 30 '15 at 13:12