3

How do you change the font used for a \marginpar? I am using xltxtra, and am seeking to use an OpenType font.

MWE:

\documentclass{book}
\usepackage{xltxtra}
\usepackage{titlesec}
\setmainfont[Ligatures=TeX]{Font A}

\begin{document}

Hello world.\marginpar{A margin note in Font B}

\end{document}
  • Nowadays loading xltxtra is not recommended, if you don't really need its features (I bet you don't). Just load fontspec. – egreg May 24 '13 at 19:32
4

If you can use marginnote there is a marginfont command (link to the manual) that you can adapt. Otherwise, perhaps using fontspec would be good enough?

\documentclass{book}

\usepackage{xltxtra}
\usepackage{lipsum}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Helvetica}

\usepackage{marginnote}
\renewcommand*{\marginfont}{\fontspec{Courier}}

\newcommand\marginparNewFont[1]{\marginpar{\fontspec{Courier}#1}}

\begin{document}
    \lipsum[1]\marginpar{\fontspec{Courier}A marginpar in Courier}
    \lipsum[1]\marginnote{A marginnote in Courier}
    \lipsum[1]\marginparNewFont{A marginparNewFont in Courier}
\end{document}

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.