# Change caption font using xelatex

I'm new to xelatex, but I've managed to change the font of the chapter, sections, and so on. Now, I want to change the global font of the float captions (figures, tables...). I've named the font "\captionfont", as you can see.

Below, you'll find a minimal working example, where I have not done any modifications. I guess the problem lies within the captionsetup. I've read a lot about setting the font, and I've now settled for this way of doing it, so if it is possible to set the caption font globally, without changing too much of the original code, it'd great.

\documentclass[12pt,a4paper,english]{report}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%---- FONTS ----
\usepackage[math-style=ISO]{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\setmainfont[Numbers={Proportional},SmallCapsFeatures={LetterSpace=6},
BoldFont={Minion Pro Bold},BoldFeatures={LetterSpace=3}]{Minion Pro}
\setmonofont{Minion Pro}
\newfontfamily\chapterfont{Neo Sans Std}
\newfontfamily\sectionfont{Neo Sans Std Medium}
\newfontfamily\captionfont{Neo Sans Std}
% ---- END FONTS ----
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{font=small,labelfont=bf,margin={0cm,0cm},justification=justified,singlelinecheck=off}

\titleformat*{\chapter}{\huge\chapterfont}

\begin{document}
Here goes some text with the font X.
\begin{figure}
\includegraphics[width=1\textwidth]{dummyfigure}
\caption{This should be font \captionfont}
\end{figure}
Here continues font X.
\end{document}


I hope someone can fix it for me :)

• How do you set the font for the titles? – egreg Jan 26 '15 at 16:46
• @egreg I'll add it to the question. Basically, I use \newfontfamily to name the font (here \chapterfont). Then I use \titleformat{\chapter}{\huge\chapterfont} to globally set the chapter font (and size using \huge). The same goes for sections etc. Be aware that \titleformat requires {titlesec}-package – Niels Møller Jan 26 '15 at 17:14
• The MWE is almost useless as it is. – Ludenticus Jan 26 '15 at 19:05
• Why? After adding \titleformat I forgot to include titlesec, so that's the only thing causing errors for me. – Niels Møller Jan 26 '15 at 21:39

This should give you the desired caption font:

\DeclareCaptionFormat{neofont}{\captionfont\small#1#2#3}
\captionsetup{format=neofont,labelfont=bf,margin={0cm,0cm},justification=justified,singlelinecheck=off}


A complete reduced example:

\documentclass[12pt,a4paper,english]{report}
\usepackage{caption}
\usepackage{fontspec}

\newfontfamily\captionfont{Neo Sans}

\DeclareCaptionFormat{neofont}{\captionfont\small#1#2#3}
\captionsetup{format=neofont,labelfont=bf,margin={0cm,0cm},justification=justified,singlelinecheck=off}

\begin{document}
Here goes some text with the main font.
\begin{figure}
\includegraphics[width=1\textwidth]{example-image-a}
\caption{This is on Neo Sans font}
\end{figure}
Here continues main font.
\end{document}


The output:

I used Neo Sans instead of Neo Sans Std, but the idea is the same.

• Great! Thanks a lot! This solves my problem, and gives me an idea to solve future look-a-like problems – Niels Møller Jan 26 '15 at 16:46