1

The problem:

Some times we have to prepare a LaTeX project on our linux and to give it to another person to run it on Windows or mac. We don't really know what TeX front-end program will the other person use and we don't really care in case of standard LaTeX code that will be compiled with pdflatex.

But in case of XeLaTeX things are somehow different. In this case, if we use TeXshop, TeXworks or TeXStudio we have to start our XeLaTeX code with some comments that other editors (or TeX front-end programs) like kile or emacs will ignore as real comments... but TeXStudio and not only will use these comments as commands to recognize that the engine it has to use is a XeTeX and not pdflatex.

The question(s):

1) I don't really know how much accurate are these that I said in "the problem" part... So I would like an answer that makes corrects my possible mistakes on the question (I have limited experience with other than texlive versions and I don't even know what we call front-end program, or TeX engine or...)

2) Adding the following "magic lines" in the first rows of our XeLaTeX file our code will be recognized of every editor/front-end program with the ability to run XeLaTeX.

% !TEX TS-program = XeLaTeX
% !TeX program = xelatex

Is this sentence correct? Do we have to follow this particular order?

3) As far as I know, XeLaTeX needs utf8 files. So we have to save our file in utf8 format before running XeLaTeX. Are there more things that we have to take care to except of the utf8-save and the two above lines to be sure that our code will run in other machines if it runs in ours? (For example, as @DavidCarlisle mentioned the font we select on our code have to be installed on the other persons system too...)

MWE (with greek):

% !TEX TS-program = XeLaTeX
% !TeX program = xelatex
\documentclass[a4paper,10pt]{article}

\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}
\setmainfont[Mapping=tex-text]{Linux Libertine O}
% \setsansfont[Mapping=tex-text]{DejaVu Sans}
% \setmonofont[Mapping=tex-text]{DejaVu Sans Mono}

\newfontfamily\greekfont{Linux Libertine O}
\title{Τίτλος Άρθρου}
\author{Όνομα Επώνυμο}
\date{}


\begin{document}
\maketitle

\section{Ενότητα με μαθηματικά}


\begin{english}
Text here more than a line that I hope it will be hyphenated 
if I add a BigEnglishWord
\end{english}

Ελληνικά που θα χρησιμοποιηθούν σαν βασικό κείμενο και θα έχουν τη 
δυνατότητα να κόβονται οι λέξεις

\end{document}

More

The real one question (because the above seems more than one) is :

What do I have to take care to be sure that my XeLaTeX code will run on every system that can run XeLaTeX? (I don't care about problems like a font that is missing or a package version is outdated... or an outdated XeLaTeX version etc... This can happen to pdflatex too. The answer is specific to XeLaTeX and the best practices to avoid compilation failure on other machines)

PS: Sorry, but probably the question started from a person (me) that have very limited knowledge on what is going on behind his editor...

  • 3
    The example works fine on windows (miktex and texlive). The OP of the other question has some outdated files. Btw: don't load xltxtra. – Ulrike Fischer Oct 15 '17 at 19:35
  • Thanks @UlrikeFischer. I will wait for a Mac user too to see if it runs on Mac too. Do you have to save the file in utf8 for both your tests? Is there something additional you have done? xltxtra is a kile (editor) suggestion for default XeLaTeX file. Thanks for the info. I will delete it from my post (Off-topic: Do you have any reason to tell me about avoiding xltxtra so I can inform kile maintainers?) – koleygr Oct 15 '17 at 19:40
  • 2
    xltxtra is outdated, see the description ctan.org/pkg/xltxtra. And yes, I did use utf8. I know how to compile a xelatex file. – Ulrike Fischer Oct 15 '17 at 19:52
  • @UlrikeFischer I didn't knew that it is a must to save as a utf8. I use utf8 language on my linux and so this is default for me. If you want answer the question please (including the xltxtra stuff if you want) – koleygr Oct 15 '17 at 19:56
  • “Doesn't work” is too generic a statement for giving suggestions. I'll vote to close as unclear if you don't add details about what is failing. – egreg Oct 16 '17 at 7:02
0

The answer for a XeLaTeX file that can be run independently of the editor/front end program that will be used, is to place the "comments-engine commands" given below in the first two lines of the file:

% !TEX TS-program = XeLaTeX
% !TeX program = xelatex

This way the engine that will be used is automatically recognized by our editor/front end program or ignored (as a comment) by it if not needed.

Another thing that became clear by the comments, is that the editor we use has to save the file in utf8 format.

Finally, the xltxtra package that been loaded by default in many editors as a MWE of XeLaTeX file, is an outdated package and has to be avoided.

Special thanks to @UlrikeFische and to @samcarter for testing the code.

Also thanks to @egreg for the info about the editor/front end to LaTeX that makes the difference and not really the OS. (see his comment below).

The wanted result is a file that can be compiled anywhere that XeLaTeX is installed without worrying of the specific editor/front end program that will be used.

I have select my own answer because there is no other answer to select from more experienced members. If another answer from someone who will show more knowledge on this topic will be added, I am going to select that as accepted.

  • 1
    Those “magic lines” have nothing to do with the operating system, but with the editor/front end to LaTeX. They aren't understood by Emacs, for instance; they are by TeXShop, TeXworks or TeXStudio but, again, this is not a cross-platform problem. – egreg Oct 15 '17 at 22:19
  • Thanks for the info @egreg. This is why I had in quotes the "cross-platform" in the title. I didn't really knew if the problem has to do with OS or with editor. Anyway, I will edit with the info you added. Thanks – koleygr Oct 15 '17 at 22:37
  • neither the question nor this answer say what "the problem" is nor how to solve it. all xelatex files are cross platform except for the issue of specifying system fonts that may not be available on all platforms, and you don't even mention fonts. – David Carlisle Oct 16 '17 at 7:07
  • @DavidCarlisle... I edited the question... Feel free to answer or to edit. – koleygr Oct 16 '17 at 8:11
  • sorry I am not sure the question can be saved by editing, The processing comments for the editors are nothing to do with xetex, they just tell the editor what program to use to process the file so they would apply equally to pdftex or luatex or any program you have on your computer. – David Carlisle Oct 16 '17 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.