0

I need to edit my previous question about caption width below the figure. The goal is to have a caption exactly the same width as the figure. I was recommended to use caption package and the command \captionsetup{width=x} to make the width of the caption the same as the width of the figure by specifying x equal to the width of the figure. However, I am doing a presentation and it seems that this is not working here, when I do this, caption is still much wider than the figure as you can see in the image attached below. enter image description here

Also, I want to use the command \setbeamertemplate{caption}{\raggedright\insertcaption\par} to get rid of the "Figure:" before the caption and this is not working either now, but if I exclude \usepackage{caption} from my preamble, it is working fine. Here is my code now:

\PassOptionsToPackage{table}{xcolor}
\documentclass[xcolor=svgnames]{beamer}

%\PassOptionsToPackage{svgnames}{xcolor}
%\documentclass[xcolor=table]{beamer}
%
% Choose how your presentation looks.
%
% For more themes, color themes and font themes, see:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%
\mode<presentation>
{
  \usetheme{Warsaw}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{default} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
%  \setbeamertemplate{caption}[numbered]
%\setbeamercolor{section in head/foot}{bg=NavyBlue}
}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{tabu}
\usepackage{booktabs}% for better rules in the table
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{caption}


\title[Thesis Defense]{Name of the thesis}
\subtitle{Thesis Defense}
\author{}
 \institute{}
\date{January 31, 2018}

\begin{document}
\setbeamertemplate{caption}{\raggedright\insertcaption\par}
\setbeamerfont{caption}{size=\tiny}

\begin{frame}[plain]
  \titlepage
\end{frame}

\begin{frame}{Motivation}
\begin{figure}
\centering
\captionsetup{width=90mm}
\small{Appreciation of house prices and policy rate} \par
%\label{fig:circulation}
\includegraphics[width=90mm,height=0.5\textheight,keepaspectratio]{WuXia_rate_Real_HPI}

\caption{\textit{Shaded area marks the pre-crisis period in which effective federal funds rate was below the Taylor rule rate.}}
%\begin{source} National central banks \end{source}
\end{figure}

\begin{itemize}
\item 
\item
\end{itemize}

\end{frame}



\end{document}
  • After answering I was looking for this question, since I remembered something analogous – Oscar Jan 29 '18 at 16:24
1

You could use the measuredfigure environment as described here (by Bernard) and shown in the following MWE:

\documentclass[xcolor=svgnames]{beamer}

\mode<presentation>
{
  \usetheme{Warsaw}
  \usecolortheme{default}
  \usefonttheme{default}
  \setbeamertemplate{navigation symbols}{}
}
\setbeamertemplate{caption}{\raggedright\insertcaption\par}
\setbeamerfont{caption}{size=\tiny}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{threeparttable}

\begin{document}
\begin{frame}{Motivation}
\begin{figure}
\centering
\small{Appreciation of house prices and policy rate} \par
\begin{measuredfigure}
\includegraphics[width=90mm,height=0.5\textheight,keepaspectratio]{example-image}
\caption{\textit{Shaded area marks the pre-crisis period in which effective federal funds rate was below the Taylor rule rate.}}
\end{measuredfigure}
\end{figure}

\begin{itemize}
\item 
\item
\end{itemize}
\end{frame}
\end{document}
| improve this answer | |
  • Thank you very much for your answer, it works fine! Would you please also have any idea how to make the space between the caption and the figure smaller in this case? I tried to use \vspace{-1cm} before the \caption command in the above code, but it does not work (even if I increase the negative number in \vspace, the caption stays in the same distance from the figure). – doremi Jan 29 '18 at 19:29
  • @doremi: You can modify \abovecaptionskip as shown here: tex.stackexchange.com/a/45996/134144 – leandriis Jan 29 '18 at 19:42
  • It's worth mentioning theis environment is fragile, and may require to be protected. – Bernard Jan 29 '18 at 19:45
  • I tried to use \belowcaptionskip with negative values, because I want to decrease the space, but it did not work for the caption below my figure in the presentation, instead, it makes the distance between the items \item ... below the figure and the figure smaller. So it works, but not for the caption, but for what text is below the figure? – doremi Jan 29 '18 at 20:00
  • @doremi: Well, \belowcaptionskip influences the space below the caption. Did you try using \abovecaptionskip instead? – leandriis Jan 29 '18 at 20:31
0

The caption package provides a width that allows you to adjust the width for each figure individually. This way you can adjust the width to suit the width of your figure. If all your figures have the same width, you can set the option \captionsetup{width=<len>} globally.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.