2

How to reduce a font size of a particular figure in \subfigure environment in beamer. I know how to reduce the caption font globally \usepackage[font=small]{subcaption}, but I am looking for a font size handling locally.

I am showing four subfigures in one frame using \subfigure from \subcaption package. The problem is the subfigure's individual captions, (a), (b), (c), (d), are way too big as compared to the labeling text which is used inside the sub-pictures. So, if I increase the individual subfigure height using \begin{subfigure}{.49\textwidth} then the four pictures go out of page, if I decrease the size of it then font which is used inside the figure becomes too small as compared to the caption. So, I want to decrease the caption font so that with respect to text used inside the picture will not look bad.

My MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{beamer}

\mode<presentation> {

% The Beamer class comes with a number of default slide themes
% which change the colors and layouts of slides. Below this is a list
% of all the themes, uncomment each in turn to see what they look like.

%\usetheme{default}
%\usetheme{AnnArbor}
%\usetheme{Antibes}
%\usetheme{Bergen}
%\usetheme{Berkeley}
%\usetheme{Berlin}
%\usetheme{Boadilla}
%\usetheme{CambridgeUS}
%\usetheme{Copenhagen}
%\usetheme{Darmstadt}
%\usetheme{Dresden}
%\usetheme{Frankfurt}
%\usetheme{Goettingen}
%\usetheme{Hannover}
%\usetheme{Ilmenau}
%\usetheme{JuanLesPins}
%\usetheme{Luebeck}
% \usetheme{Madrid}
%\usetheme{Malmoe}
%\usetheme{Marburg}
%\usetheme{Montpellier}
%\usetheme{PaloAlto}
%\usetheme{Pittsburgh}
%\usetheme{Rochester}
%\usetheme{Singapore}
%\usetheme{Szeged}
\usetheme{Warsaw}

% As well as themes, the Beamer class has a number of color themes
% for any slide theme. Uncomment each of these in turn to see how it
% changes the colors of your current slide theme.
\useoutertheme{infolines}
%\usecolortheme{albatross}
%\usecolortheme{beaver}
%\usecolortheme{beetle}
%\usecolortheme{crane}
%\usecolortheme{dolphin}
%\usecolortheme{dove}
%\usecolortheme{fly}
%\usecolortheme{lily}
%\usecolortheme{orchid}
%\usecolortheme{rose}
%\usecolortheme{seagull}
%\usecolortheme{seahorse}
%%\usecolortheme{whale}
%\usecolortheme{wolverine}

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

% % % Black Background Configuration
%\setbeamercolor{normal text}{fg=white,bg=black!90}
%\setbeamercolor{structure}{fg=white}
%
%\setbeamercolor{alerted text}{fg=red!85!black}
%
%\setbeamercolor{item projected}{use=item,fg=black,bg=item.fg!35}
%
%\setbeamercolor*{palette primary}{use=structure,fg=structure.fg}
%\setbeamercolor*{palette secondary}{use=structure,fg=structure.fg!95!black}
%\setbeamercolor*{palette tertiary}{use=structure,fg=structure.fg!90!black}
%\setbeamercolor*{palette quaternary}{use=structure,fg=structure.fg!95!black,bg=black!80}
%
%\setbeamercolor*{framesubtitle}{fg=white}
%
%\setbeamercolor*{block title}{parent=structure,bg=black!60}
%\setbeamercolor*{block body}{fg=black,bg=black!10}
%\setbeamercolor*{block title alerted}{parent=alerted text,bg=black!15}
%\setbeamercolor*{block title example}{parent=example text,bg=black!15}

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

%\setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line
%\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line

%\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
}

\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{epstopdf}
\usepackage[font=small,skip=0pt]{caption}
\usepackage[backend=bibtex]{biblatex}

%\usepackage{IEEEtrantools.sty} %Copy file IEEEtran.sty to folder where miktek is installed i-e E:\Program Files\MiKTeX 2.9\tex\latex\IEEEtran.sty
\usepackage[retainorgcmds]{IEEEtrantools} %For TexLive

\usepackage{comment}
%\bibliography{references}
%\usepackage{bibentry}

%\usepackage{mathtools}
%\usepackage{verbatim}

\usepackage[disable,colorinlistoftodos]{todonotes}
%\usepackage[obeyDraft,colorinlistoftodos]{todonotes}

\usepackage{subcaption}

\beamertemplatenavigationsymbolsempty 
\usepackage[framemethod=tikz]{mdframed} %for slide transition
\setbeamertemplate{caption}[numbered] %To achieve numbering of figures, you need to set.



\begin{document}

%-----------------------------------------------------------

%------------------------------
\begin{frame}
\begin{figure}[h!]
    \begin{subfigure}{.49\textwidth}
        %           \centering
        \includegraphics[width=1\linewidth]{f22.eps}
        \caption{ }
        \label{fig7a}
    \end{subfigure} 
    \begin{subfigure}{.49\textwidth}
        %           \centering
        \includegraphics[width=1\linewidth]{f23.eps}
        \caption{ }
        \label{fig7b}
    \end{subfigure} \\%
    \begin{subfigure}{.49\textwidth}
%       \centering
        \includegraphics[width=1\linewidth]{f24.eps}
        \caption{ }
        \label{fig7c}
    \end{subfigure} %
    \begin{subfigure}{.49\textwidth}
        %           \centering
        \includegraphics[width=1\linewidth]{f25.eps}
        \caption{ }
        \label{fig7d}
    \end{subfigure}
    \caption{\textbf{My caption}
    \label{f7}
\end{figure}
\end{frame}

\end{document} 
  • 1
    Can you please make your example to a MWE? By removing all the unnecessary lines in the preable you will make it much more clearer. Furthermore, you do not need graphicx in beamer, beamer itself already provides it. There is no need for placement options like [h!] in a class without floating elements like beamer. Finally there is a missing } after "my caption". – user36296 Apr 17 '16 at 9:46
4

I would add the instruction

\captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}

after \begin{figure}. That way, the setup change is local to this particular figure environment.

A full MWE:

enter image description here

\documentclass[demo]{beamer}

\mode<presentation> {
\usetheme{Warsaw}
\useoutertheme{infolines}
}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs}
\usepackage{epstopdf}
\usepackage[font=small,skip=0pt]{caption}
\usepackage[backend=bibtex]{biblatex}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage{comment}
\usepackage[disable,colorinlistoftodos]{todonotes}
\usepackage{subcaption}
\beamertemplatenavigationsymbolsempty 
\usepackage[framemethod=tikz]{mdframed} 
\setbeamertemplate{caption}[numbered]

\begin{document}

\begin{frame}
\begin{figure}[h!]
    \captionsetup[subfigure]{font=scriptsize,labelfont=scriptsize}
    \begin{subfigure}{.49\textwidth}
        \includegraphics[width=1\linewidth]{f22.eps}
        \caption{Hello World}
        \label{fig7a}
    \end{subfigure} \hspace*{\fill}
    \begin{subfigure}{.49\textwidth}
        \includegraphics[width=1\linewidth]{f23.eps}
        \caption{Good Morning}
        \label{fig7b}
    \end{subfigure} 

    \begin{subfigure}{.49\textwidth}
        \includegraphics[width=1\linewidth]{f24.eps}
        \caption{Good Night}
        \label{fig7c}
    \end{subfigure} \hspace*{\fill}
    \begin{subfigure}{.49\textwidth}
        \includegraphics[width=1\linewidth]{f25.eps}
        \caption{Goodbye World}
        \label{fig7d}
    \end{subfigure}
    \caption{\textbf{My caption}}
    \label{f7}
\end{figure}
\end{frame}

\end{document}

Addendum: If you want the overall figure caption to show up in the frame, you must reduce the sizes of the images, maybe along the lines of the following example.

enter image description here

\documentclass[demo]{beamer} % remove 'demo' option in real document

\mode<presentation> {
\usetheme{Warsaw}
\useoutertheme{infolines}
}
\usepackage{booktabs}
\usepackage[font=small,skip=0pt]{caption}
\usepackage[backend=bibtex]{biblatex}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage{comment}
\usepackage[disable,colorinlistoftodos]{todonotes}
\usepackage{subcaption}
\beamertemplatenavigationsymbolsempty 
\usepackage[framemethod=tikz]{mdframed} 
\setbeamertemplate{caption}[numbered]

\begin{document}

\begin{frame}
\captionsetup[figure]{labelfont=scriptsize,
                      textfont={scriptsize,bf}}
\captionsetup[subfigure]{labelfont=scriptsize,
                         textfont=scriptsize}

\begin{figure}[h!]
    \centering
    \begin{subfigure}{.4\textwidth}
    \includegraphics[width=1\linewidth,height=0.2\textheight,keepaspectratio]{f22.eps}
    \caption{Hello World}
    \label{fig7a}
    \end{subfigure} \qquad
    \begin{subfigure}{.4\textwidth}
    \includegraphics[width=1\linewidth,height=0.2\textheight,keepaspectratio]{f23.eps}
    \caption{Good Morning}
    \label{fig7b}
    \end{subfigure} 

    \begin{subfigure}{.4\textwidth}
    \includegraphics[width=1\linewidth,height=0.2\textheight,keepaspectratio]{f24.eps}
    \caption{Good Night}
    \label{fig7c}
    \end{subfigure} \qquad
    \begin{subfigure}{.4\textwidth}
    \includegraphics[width=1\linewidth,height=0.2\textheight,keepaspectratio]{f25.eps}
    \caption{Goodbye World}
    \label{fig7d}
    \end{subfigure}

\caption{My caption}
\label{f7}
\end{figure}

\end{frame}

\end{document}
  • How to do the same to reduce the font size of the caption of the four subfigures. – kaka Apr 17 '16 at 19:15
  • @kaka - Not sure I understand your comment. scriptsize represents a 30% linear reduction in the font size. Are you asking how the font size might be reduced even further? – Mico Apr 17 '16 at 19:25
  • I mean how to reduce the size of \caption{\textbf{My caption}} in above code. It is also not visible in the frame. – kaka Apr 17 '16 at 20:20
  • 1
    Ah, you mean the caption of the figure, not of the subfigures. How about \captionsetup[figure]{font=scriptsize,labelfont=scriptsize}? Incidentally, the figure caption isn't visible because the images are too large, crowding out some of the other material. I would reduce both the widths and the heights of the images. – Mico Apr 17 '16 at 20:24
2

Redefining \thesubfigure and restoring it to normal font size afterwards gives the desired results:

\documentclass{beamer}

\usetheme{Warsaw}
\useoutertheme{infolines}

\usepackage{caption}
\usepackage[labelformat=simple]{subcaption}

\setbeamertemplate{caption}[numbered] 

\captionsetup{font=bf}

\renewcommand\thesubfigure{\normalfont(\alph{subfigure})}

\begin{document}

    \begin{frame}
        \begin{figure}[h!]
            \begin{subfigure}{.49\textwidth}
                \renewcommand\thesubfigure{\fontsize{5}{8}\selectfont (\alph{subfigure})}
                \includegraphics[width=1\linewidth]{pic}
                \caption{ }
                \label{fig7a}
                \renewcommand\thesubfigure{\normalfont (\alph{subfigure})}
            \end{subfigure} 
            \begin{subfigure}{.49\textwidth}
                \includegraphics[width=1\linewidth]{pic}
                \caption{ }
                \label{fig7b}
            \end{subfigure}
            \caption{My caption}
            \label{f7}
        \end{figure}
    \end{frame}

\end{document} 

enter image description here

Remarks

  • no need for graphicx in beamer, beamer itself already provides it
  • also no need for placement options like [h!] in beamer, as beamer disables floating mechanism.
  • thanks. It helps. I accept Mico's answer, as it is more easy for me to understand. – kaka Apr 17 '16 at 19:16

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.