1

I made a lot of research ins this forum, readjusted and tried all commands, but setting both font family and font size together, using DeclareCaptionFont does not work.

1st code, by me:

\usepackage{caption}
\newfontfamily\cantarell{Cantarell}
\DeclareCaptionFont{cantarell}{\cantarell\fontsize{5}{7}}
\captionsetup{font=cantarell}

2nd alt, taken from https://tex.stackexchange.com/a/225025/172831:

\usepackage{caption}
\newfontfamily\cpfont{Cantarell} 
\DeclareCaptionFormat{iosfont}{\cpfont\tiny}
\captionsetup{format=iosfont,labelfont=bf,margin={0cm,0cm},justification=centering,singlelinecheck=on}
  • I want to set Cantarell or any font family
  • I want to set 5px or 7px. The command tiny does not work, either.
  • 1
    Welcome to TeX.SX! Please help us help you by providing a minimal compilable code example (MWE). – TeXnician Oct 27 '18 at 7:25
1

You forgot to use \selectfont, but the simplest is to switch the size declaration and the font declaration.

\documentclass{article}
\usepackage{fontspec}
\usepackage{caption}

\newfontfamily\cantarell{Futura}% sorry, no Cantarell

\DeclareCaptionFont{cantarell}{\fontsize{5}{7}\cantarell}
\captionsetup{font=cantarell}

\begin{document}

\begin{figure}

some text in the standard font for comparison
some text in the standard font for comparison
some text in the standard font for comparison
some text in the standard font for comparison

\caption{some text in the caption font for comparison
some text in the caption font for comparison
some text in the caption font for comparison
some text in the caption font for comparison
some text in the caption font for comparison
some text in the caption font for comparison}

\end{figure}

\end{document}

Since I don't have easily accessible Cantarell fonts, I just used a very distinctive one I have on my machine.

enter image description here

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.