3

How can I do the macro which will automatilcally choose font if compiles on Win (TNR font) or on Linux (Liberation for example). Using XeTex (TeXLive).

\documentclass[12pt]{article}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=modern]{russian}
\setotherlanguage{english}
\setmainfont{Liberation Serif} %want to choose Liberation on Linux, TNR in Win
\newfontfamily\cyrillicfonttt[Script=Cyrillic, Scale=0.8]{Ubuntu-Light}
  • 3
    There seems to be a package ifplatform. I have not tried it but this is the first result I found on CTAN. – Artemis Jan 16 '17 at 15:41
  • 2
    Maybe you can "simply" put one of the fonts as fall back if the other does not exist, see tex.stackexchange.com/a/53448/36296 – user36296 Jan 16 '17 at 15:55
  • @Artemis great! very powerful macro, thank you for the answer – Vasya Pravdin Jan 16 '17 at 16:05
  • @samcarter thank you, sometimes the best way is simplest way . – Vasya Pravdin Jan 16 '17 at 16:06
5

As already stated in a comment there is a package called ifplatform which can solve this problem. It should work also for LuaLaTeX and pdfLaTeX, not just XeTeX.

Attention: Keep the warning from the documentation in mind, that all macros except \ifwindows do not work as expected unless --shell-escape is enabled.

For your example the solution would be best written as:

\usepackage{ifplatform}
\ifwindows
% Load Windows font here
\else
% Load Non-Windows font here
\fi
  • Thank you! Because of my limited experience, I would have understood this much longer. – Vasya Pravdin Jan 17 '17 at 7:07

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.