I got some LaTeX documents that I have to compile them under different TeX Live, such as MacTeX or TeX Live. But in different OS, the font seems different too, for example, while in Windows, I prefer to use Cambria, but in Mac, I like Lucida Grande more.

Is there was a macro to differentiate between OS?

Answer Update

As the accepted answer, We need to add more comments on this question, As I read the package manual, we need more settings to use these macros:

% packages we need

Then we use these macros like that

% add settings
% add settings
% add settings
\fi % This needs to be \fi, not \if

now, it works well, the point is you need more packages not only ifplatform.

one more thing, compile your tex file with option -shell-escape is required:

xelatex -shell-escape file.tex

1 Answer 1


the ifplatform package provides \ifwindows, \iflinux, \ifmacosx and \ifcygwin conditionals. i would think that would be enough; the package requires shell escape to be enabled.

  • 5
    I like how Cygwin is strange enough it counts as a separate OS.
    – Canageek
    Nov 28, 2012 at 15:55
  • 3
    @Canageek Cymwin 'looks like' *nix, but Windows is 'around'. From memory, there were various requests to be able to differentiate Cygwin from Linux (and of course from Mac OS X, OpenBSD, ...).
    – Joseph Wright
    Nov 28, 2012 at 15:59
  • Cygwin is not a question, just do jobs in Windows.
    – coanor
    Nov 29, 2012 at 8:20
  • Note that for \ifwindows shell escape is not needed, only for the other OSes. So without shell escape you can detect Windows vs. non-Windows (but not which kind of non-Windows).
    – Marijn
    Mar 19 at 21:14

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.