# Custom font size for captions

This code is fine:

\usepackage{caption}
\captionsetup{
font=small,
labelfont=bf,
justification=justified,
format=plain}


But I want to customise my font like this:

\usepackage{caption}
\captionsetup{
font={\fontsize{10pt}{11pt}\selectfont},
labelfont=bf,
justification=justified,
format=plain}


The latter code gives a compile error. Help?

Here is a minimal example that includes the code that doesn't work:

\documentclass{article}

\usepackage{caption}
\captionsetup{
font={\fontsize{10pt}{11pt}\selectfont},
labelfont=bf,
justification=justified,
format=plain}

\begin{document}

\begin{figure}
\caption{A figure caption}
\end{figure}

\end{document}

• the font key as you show takes a name not a fragment of tex code. (incidentally it's always better to provide a complete test document,helps people to test answers) – David Carlisle Dec 28 '19 at 17:52
• But whatever is relevant code ... – Fran Dec 28 '19 at 17:52
• in most classes 10pt is the default size, so what is the intention of \fontsize{10pt}{11pt}\selectfont other than slightly reducing the line spacing? – David Carlisle Dec 28 '19 at 17:55
• For future reference: Even thought you want to "just show the important parts" in terms of code, those who want to answer the question have to type the surrounding filler anyway, so you might just as well add that content. – Werner Dec 28 '19 at 18:03

You need to define the new font style, since caption requires this as part of its key-value input:

\documentclass{article}

\usepackage{caption}

\DeclareCaptionFont{myfont}{\fontsize{10pt}{11pt}\selectfont}

\captionsetup{
font=myfont,
labelfont=bf,
justification=justified,
format=plain
}

\begin{document}

\begin{figure}
\caption{This is a caption}
\end{figure}

\end{document}

• Perfect! Thanks a lot :-D – Matt Dec 28 '19 at 18:02