0

I am trying to use a display font for special headers -- it is Anton in truetype format, but to continue to use normal Latex fonts for the rest of the document. I thought this would be achieved by

\usepackage{droid}
\usepackage{ifxetex}
\ifxetex
  \usepackage{fontspec}
  \defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
  \newfontfamily\headerfont{Anton}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\fi

but if this is compiled by xelatex, the droid package is ignored, and if by pdflatex, the Anton font is not available. Is there a way round this problem?

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please post code we can copy-paste-compile to see the problem: a minimal working example (MWE). This makes it a lot easier to help!
    – cfr
    Dec 10, 2014 at 0:34

1 Answer 1

3

\ifxetex detects whether you are compiling with XeTeX or not. If you are, it executes the if bit. If not, it executes the else bit. Moreover, you cannot use inputenc with XeTeX (so it is good, really, that that code is never read).

You can use 'normal LaTeX fonts' for the rest of the document, though. Just use the three lines of code from \usepackage{fontspec} and put \usepackage{droid} configuration afterwards, as loading fontspec sets the default families to Latin Modern.

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
\newfontfamily\headerfont{Quintessential}
\usepackage[T1]{fontenc}
\usepackage{droid}
\begin{document}
Some text.
\end{document}

However, you may prefer to use the Droid fonts in opentype/truetype format to take full advantage of XeTeX.

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
\newfontfamily\headerfont{Quintessential}
\setmainfont{Droid Serif}
\setsansfont{Droid Sans}
\setmonofont{Droid Sans Mono}
\begin{document}
  Some text. Serif. \textsf{Sans}. \texttt{Mono}.
\end{document}

Droid truetype

Note that I changed the value of \headerfont to prevent XeLaTeX hanging forever since I don't have the font you are using.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .