5

I want to change the font size of the label of a figure environment to any font size. It's possible to use the package caption with the argument font=Large for example. But I found no way to choose any font size, e.g. fontsize=28pt.

Here an example code:

\documentclass{standalone}
\usepackage{anyfontsize}

\usepackage[font=Large]{caption}
%\usepackage[fontsize=28pt]{caption} % not implemented


\begin{document}
\parbox[t]{20cm}{

\fontsize{28}{30} \selectfont

\begin{figure}
    %\includegraphics{figure.eps}
    \caption{\label{fig_req_osnr} \fontsize{28}{30} \selectfont My caption.}
\end{figure}

}

\end{document}

enter image description here

Do you have any ideas?

1

2 Answers 2

7

You can define a new value for font with \DeclareCaptionFont:

\documentclass{article}
\usepackage{anyfontsize}

\usepackage{caption}
\DeclareCaptionFont{xxviii}{\fontsize{28}{32}\selectfont}
\captionsetup{font=xxviii}


\begin{document}
\begin{figure}
\centering
\fbox{\rule{0pt}{4cm}\rule{4cm}{0pt}}
\caption{My caption}\label{fig_req_osnr}
\end{figure}

\end{document}

enter image description here

3

You can use

\makeatletter
  \l@addto@macro\captionfont{\fontsize{28}{30}\selectfont}
\makeatother

to change the fontsize for the whole caption.

enter image description here

Code:

\documentclass{standalone}
\usepackage{anyfontsize}

\usepackage{caption}
\makeatletter
  \l@addto@macro\captionfont{\fontsize{28}{30}\selectfont}
\makeatother

\begin{document}
\parbox[t]{10cm}{
  \begin{figure}
    \centering \fbox{Figure}
    \caption{\label{fig_req_osnr} My caption.}
  \end{figure}
}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .