[Tex/LaTex] Size and position of the table caption

captionsfontsize

I need a caption of my table/figure to be 9pt size. The whole text should stay 12pt-sized, while only table/figure caption should be 9pt size.

I also need the caption to appear above the table, and below the figure (I managed to do this, see MWE below). Unfortunately, I can't really work out how to handle caption sizes. I tried: \fontsize{9}{11}\selectfont {\caption{My awesome table}} with no effect (the effect was that the text INSIDE the table was modified to fit 9pt size, caption stayed the same …).

Any ideas? Thank you so much for help and your time!

\documentclass[12pt]{article}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage[draft]{pgf}

\floatsetup[table]{capposition=top}
\floatsetup[figure]{capposition=bottom}

\begin{document}

\begin{table}
    \fontsize{9}{11}\selectfont {\caption{My awesome table}}
    \begin{tabular}{*4{l}}
        A & B & C & D\\
        x & w & y & z\\
        1 & 2 & 3 & 4\\
    \end{tabular}
\end{table}

\begin{figure}
\centering
  \begin{pgfpicture}
    \pgftext{\pgfimage[width=5cm,height=4cm]{scratch.png}}
\end{pgfpicture}
  \fontsize{9}{11}\selectfont {\caption{My awesome picture}}
\end{figure}

\end{document}

Best Answer

Something like this. Move \fontsize{9}{11}\selectfont into the caption {}.

enter image description here

Code

\documentclass[12pt]{article}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage[draft]{pgf}

%\usepackage[font={scriptsize}]{caption}  % if only the word `Caption` and `Figure` needs to be small too.

\floatsetup[table]{capposition=top}
\floatsetup[figure]{capposition=bottom}

\begin{document}

\begin{table}
   \caption{\fontsize{9}{11}\selectfont My awesome table}
    \begin{tabular}{*4{l}}
        A & B & C & D\\
        x & w & y & z\\
        1 & 2 & 3 & 4\\
    \end{tabular}
\end{table}


\begin{table}
   \caption{My awesome table}
    \begin{tabular}{*4{l}}
        A & B & C & D\\
        x & w & y & z\\
        1 & 2 & 3 & 4\\
    \end{tabular}
\end{table}

\begin{figure}
\centering
  \begin{pgfpicture}
    \pgftext{\pgfimage[width=5cm,height=4cm]{scratch.png}}
\end{pgfpicture}
\caption{\fontsize{9}{11}\selectfont My awesome picture}
\end{figure}
\end{document}