1

I'm having problems with the droid font style, since according to its documentation by just loading it on the document it changes the default font. It also changes the font that minted uses for typesetting the code, and I just want to use it on the titlepage and then, use the default LaTeX font for the whole document. Consider this example:

\documentclass{article}
\usepackage{fontspec} % I'm using XeLaTeX
\usepackage{droid}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[RO]{}
\fancyhead[RO]{\textbf{\rightmark}}
\fancyfoot{}
\fancyfoot[LE,RO]{\fontfamily{lmr}\selectfont\thepage}

\begin{document}
    \begin{titlepage}
        \centering
        My title with droid font
    \end{titlepage}
    \fontfamily{lmr}\selectfont
    \section{A section}
    This text is in lmr style, but not the section title.
\end{document}
1

You have a few issues here. One is that you’re trying to mix legacy NFSS font families and modern fonts with fontspec. (This is possible, but more complicated than you need.) The second is that you want to format your chapter/section titles, but you haven’t loaded a package to do that (such as KOMA-Script’s scrlayer or titlesec). A third, trivial one is that you’re using even and odd pages without the twoside option to your document class.

Here’s a really ugly hack that makes only the minimal changes to your document:

\documentclass[twoside]{article}
\usepackage{fontspec} % I'm using XeLaTeX
\usepackage{fancyhdr}

\defaultfontfeatures{Scale=MatchLowercase}
\newfontfamily\DroidSerif{Droid Serif}

\pagestyle{fancy}
\fancyhead{}
\fancyhead[RO]{\textbf{\rightmark}}
\fancyfoot{}
\fancyfoot[LE,RO]{\fontfamily{\rmdefault}\thepage}

\begin{document}
    \begin{titlepage}
        \centering\DroidSerif
        My title with droid font
    \end{titlepage}
    \section{\DroidSerif A section}
    This text is in lmr style, but not the section title.
\end{document}

This is so basic, the section number is in a different font than the section title.

Here is a more full-featured solution using KOMA-Script:

\documentclass[headsepline, twoside]{scrartcl}
\usepackage{fontspec} % I'm using XeLaTeX
\usepackage{scrlayer-scrpage}

\defaultfontfeatures{Scale=MatchLowercase}
\newfontfamily\DroidSerif{Droid Serif}

\title{My Title with Droid Serif}
\author{Martin}

\pagestyle{scrheadings}
\lefoot{\pagemark}
\rofoot{\pagemark}
\automark[section]{section}
\automark*[subsection]{}

\addtokomafont{pagehead}{\DroidSerif\bfseries\upshape}
\addtokomafont{pagefoot}{\rmfamily}
\addtokomafont{title}{\DroidSerif}
\addtokomafont{section}{\DroidSerif}
\addtokomafont{subsection}{\DroidSerif}

\begin{document}
    \begin{titlepage}
       \maketitle
    \end{titlepage}

    \section{A section}
    This text is in lmr style, but not the section title.

    \newpage
    Lorem ipsum dolor sit amet.
\end{document}

If you’re required to use PDFLaTeX, you need to remove \usepackage{fontspec} and add the appropriate NFSS commands. Load droid, and then lmodern to override it. The font family of Droid Serif is fdr. Although I don’t recommend this if you can use XeLaTeX, here’s a MWE:

\documentclass[headsepline, twoside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc} % The default since 2018
\usepackage{droid}
\usepackage{lmodern}
\usepackage{scrlayer-scrpage}

\newcommand\DroidSerif{\fontfamily{fdr}\selectfont}

\title{My Title with Droid Serif}
\author{Martin}

\pagestyle{scrheadings}
\lefoot{\pagemark}
\rofoot{\pagemark}
\automark[section]{section}
\automark*[subsection]{}

\addtokomafont{pagehead}{\DroidSerif\bfseries\upshape}
\addtokomafont{pagefoot}{\rmfamily}
\addtokomafont{title}{\DroidSerif}
\addtokomafont{section}{\DroidSerif}
\addtokomafont{subsection}{\DroidSerif}

\begin{document}
    \begin{titlepage}
       \maketitle
    \end{titlepage}

    \section{A section}
    This text is in lmr style, but not the section title.

    \newpage
    Lorem ipsum dolor sit amet.
\end{document}
  • Using \newfontfamily\myfont{<name of font>} did not solved the problem at all, as this tutoral suggests (I'm using XeLaTeX). I've followed the steps to install the font manually using the instructions here and here (supposingly) without errors. Could you post a compilable code? – Martín Jun 8 at 12:10
  • @Martin How’s this? – Davislor Jun 8 at 22:19
  • Thank you! As I progress with LaTeX over the years it becomes more and more complicated, specially font-related topics. – Martín Jun 9 at 1:28

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.