0

Purpose: control line spacing inside a figure caption for the beamer class.

I can control the font size with:

\setbeamerfont{caption}{size=\scriptsize} 

How can I control linespacing?

Until a few minutes ago I was using the caption package with various options. The caption package is not recommended with the beamer class, which wasn't a problem until a LaTeX package update broke everything (I tried to roll back the update, but did not manage). I would like to do away with the caption package altogether. I used to have this:

\makeatletter
\newcommand\hyper@makecurrent[1]{}
\makeatother
\usepackage{caption}
\captionsetup{%
  compatibility = {false},% fix for bug in beamer/caption, January 2014
  justification = {justified},
  singlelinecheck = {false},%turns off centering of short captions
  font = {scriptsize,singlespacing},%
  labelfont = {small},%
  labelsep = {space},%
  belowskip=0pt,% skip between caption and surrounding text
  aboveskip=6pt,% skip between table content and caption
  parskip = \baselineskip,% skip between lines
  labelformat = {empty},% 
  figurename = {},%clear labelformat if used
  tablename = {}%clear labelformat if used
}%

So to the extent that it is possible, I would like to replicate this output:

enter image description here

For information, the caption package gives the following error message:

 Package caption Info: Begin \AtBeginDocument code.
 Package caption Info: End \AtBeginDocument code.
  ! Undefined control sequence.
  <argument> \@@magyar@captionfix 

l.22 \begin{document}

I am primarily interested in not using the caption package. I have on several occasions applied patches to fix incompatibility issues, but the latest breakage motivates me to do away with the package (I still use it very happily with the article class!).

In addition to \setbeamerfont{caption}{size=\scriptsize}, I have tried \setbeamerfont{caption}{size*={8pt}{6pt}}, but the second argument (6pt) is ignored. I have tried to add \selectfont{} and linespread{0.5} and a few other things, to no avail.

This is what I get currently. I want much less inter-line spacing.

enter image description here

MWE:

\PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor}% named colors
\documentclass[11pt,table,t]{beamer}
\setbeamertemplate{navigation symbols}{} 
\setbeamertemplate{caption}{\insertcaption}% removes colon in caption
\setbeamerfont{caption}{size=\scriptsize}

\begin{document}
\begin{frame}
\begin{figure}
\centering
\includegraphics[width=\linewidth,height=0.7\textheight,keepaspectratio]%
{Okies-on-highway-Dorothea-Lange-1938}
\caption{\textbf{Okies:} They were refugees from the Southern Plains farms who migrated to California in the 1930s to escape the Great Depression and the Dust Bowl. This family traveled $124$ miles on foot across Oklahoma. Californians used the term ``Okies'' as an insult and it stuck. Image: Dorothea Lange, ``Family walking on highway, five children'', Works Progress Administration, Library of Congress, June 1938.} 
\end{figure}
\end{frame}
\end{document}

1 Answer 1

1

You must end the paragraph before closing the caption. See this answer for more information. On another note, you can pass options usenames, dvipsnames and svgnames of the xcolor package differently (which can be found in Page 19 of the beamer documentation).

\documentclass[xcolor={usenames,dvipsnames,svgnames},11pt,table,t]{beamer}
% Pass options of `xcolor' like the above
\setbeamertemplate{navigation symbols}{} 
\setbeamertemplate{caption}{\insertcaption}% removes colon in caption
\setbeamerfont{caption}{size=\scriptsize}

\begin{document}
\begin{frame}
\begin{figure}
\centering
I don't have your picture
\caption{\textbf{Okies:} They were refugees from the Southern Plains farms
    who migrated to California in the 1930s to escape the Great Depression
    and the Dust Bowl. This family traveled $124$ miles on foot across Oklahoma.
    Californians used the term ``Okies'' as an insult and it stuck.
    Image: Dorothea Lange, ``Family walking on highway, five children'',
    Works Progress Administration, Library of Congress, June 1938.\par}% End paragraph
\end{figure}
\end{frame}
\end{document}

line spacing corrected

6
  • Thank you! It seems so simple. I wonder: can I redefine \caption to always have a paragraph break at the end? I have dozens of presentations that would be affected, it would be quite tedious to change every file (but yes I know how to do it in bulk). As for the options of the xcolor package, that's a line I did not intend to include, but your alternative way of including it in the documentclass is nice. Thanks!
    – PatrickT
    Jul 13, 2018 at 16:36
  • @PatrickT Unfortunately, \setbeamerfont{caption}{...} “forgets” to take care of the paragraph break, which IMHO is by design: Don’t include large chunk of text in a presentation slide. The alternative solution would be using \usepackage{caption} \captionsetup{font=scriptsize,labelformat=empty}. Jul 13, 2018 at 16:52
  • Thanks. I have a workaround (works so far, but not extensively tested). Feel free to include it to your answer, which I'll accept anyway. Here the workaround: \let\origcaption\caption and \renewcommand\caption[2][]{\origcaption{#2\par}}. This I found here: tex.stackexchange.com/questions/99839/…
    – PatrickT
    Jul 13, 2018 at 16:54
  • As explained, the caption package no longer works (I have the latest texlive for MacOS updated and all, and the MWE above fails), so it's not a solution. But the workaround I give redefines the \caption command and seems to work well.
    – PatrickT
    Jul 13, 2018 at 16:57
  • @PatrickT The caption solution worked just fine in my TeX distribution (MiKTeX on Windows). You may want to check the update. Can’t say for sure. Jul 13, 2018 at 17:01

You must log in to answer this question.

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