# Changing the font spacing in figure/table captions

I am writing a thesis. Both the body of the text and my figure/table captions are double-spaced. However, I need my captions to be single-spaced. I tried resetting the spacing on the captions using \captionsetup, but it didn't seem to have any effect.

I am including sample code below.

%  thesis.tex  2014-08-08  Mark Senn
%
%  This is the root file for a simple example thesis.
%  This example can also be used to prepare a dissertation.

% See
%     http://www.ecn.purdue.edu/~mark/puthesis/#Options
% for documentclass options.
% CHANGE NEXT LINE?
\documentclass[me,thesis]{puthesis}

\usepackage{amsmath}
\usepackage{multicol}
\usepackage{subfigure}

% Force LaTeX not to hyphenate words that have less than three letters on each side of the hyphen.
\lefthyphenmin4
\righthyphenmin4

% For multi-row cells and broken lines in tables
\usepackage{multirow}
\usepackage{hhline}
\usepackage{caption}

% Captions generally show both a period and a colon.  This suppresses the colon and leaves only the period.
\captionsetup{labelsep=none}

% Try getting the captions to be single spaced.
\captionsetup[table]{font=singlespacing}
\captionsetup[figure]{font=singlespacing}

% For forcing figure placement where necessary
\usepackage{float}

% Automatically wrap around text when using "verbatim" environment.
\usepackage{listings}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true
}

\usepackage{pdflscape}
%\usepackage{capt-of}

% Title of thesis (used on cover and in abstract).
% Use \title{Put Title Here} for a one-line title.
% Use \\ to separate lines in multi-line titles.
% Put % at the end of the last line of a title
% to avoid getting an extra space in the abstract.

\title{%
An Example Thesis Done with LaTeX\\
That Has a Long Title%
}

% First author name with first name first is used for cover.
% Second author name with last name first is used for abstract.
% Your full name as it appears in the University records appears
% on the cover.
% There are two forms of author, with and without initials.
% There are examples of both below.
\author{Ivan S. Bogdanovich}{Bogdanovich, Ivan S.}

% First is long title of degree (used on cover).
% Second is abbreviation for degree (used in abstract).
% Third is the month the degree was (will be) awarded (used on cover
% and in abstract).
% Last is the year the degree was (wlll be) awarded (used on cover
% and in abstract).
\pudegree{Master of Science and Mechanical Engineering}{MSME}{July}{2014}

% Major professor (used in abstract).
\majorprof{Heinrich von Weltschmerz}

% Campus (used only on cover)
\campus{Fort Wayne}

% My command definitions specific to my thesis.

% Let typing "\en" be exactly the same as typing "\ensuremath".
\let\en=\ensuremath

% Set things up so \margins will show where the margins on the page are.
\newcommand{\margins}{\Repeat{Show where the margins for the page are.}{4}}

% Define a \ve command with two arguments, so if it called with
%     \ve an
% it will expand to
%     {\en{a_1},~\en{a_2},\ \ldots,~\en{a_{n}}}
\newcommand{\ve}[2]{\en{#1_1},~\en{#1_2},\ \ldots,~\en{#1_{#2}}}

% To LaTeX only some parts of your thesis put the
% names of the parts to include here.  For example,
% \includeonly{front} would only process front.tex.
% \includeonly{front,introduction} would only process
% front.tex and introduction.tex.
% To print the final copy of your thesis put a '%'
% in front of the \includeonly command and run LaTeX
% three times to make sure that all cross-references
% are correct.  Then run BibTeX once and LaTeX twice
% more.
% CHANGE NEXT LINE?
%\includeonly{front,introduction}

\begin{document}

% Start a new volume for your thesis.
% All theses must have at least one volume.
% If your thesis has multiple volumes put another "\volume"
% command between chapters below.
\volume

\chapter{Sample Chapter}

This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.  This is a sample paragraph.

Sample table below.

\begin{table}[h]
\centering
\caption{This is a sample table caption.  This is a sample table caption.  This is a sample table caption.  This is a sample table caption.  This is a sample table caption.  This is a sample table caption.}
\begin{tabular}{l|c|c|c|c}
\hline
& \bf 1 & \bf 2 & \bf 3 & 4 \\
\hline
\bf 5 & 6  & 7  & 8  & 9  \\
\hline
\end{tabular}
\label{Tab1}
\end{table}

Sample figure below.

\begin{figure}[h]
\centering
\caption{This is a sample figure caption.  This is a sample figure caption.  This is a sample figure caption.  This is a sample figure caption.  This is a sample figure caption.  This is a sample figure caption.}
\label{Fig1}
\end{figure}

\end{document}

• Off-topic but possibly of some relevance anyway: You have the following comment in your preamble: "Force LaTeX not to hyphenate words that have [fewer] than three letters on each side of the hyphen." If that's the objective, the instructions should be \lefthyphenmin3 and \righthyphenmin3, respectively. – Mico Nov 2 '15 at 20:30
• I tried changing it just in case. No effect. – Daniel Nov 2 '15 at 20:37
• "No effect" is rather unspecific. Please provide a bit more detail. – Mico Nov 2 '15 at 20:43
• It doesn't change the look of the tables at all. I may have just forgotten to update my comment. – Daniel Nov 2 '15 at 20:49
• Note that I prefaced my comment with "Off-topic but..." It was thus certainly not intended to address the spacing issues. What I did want to achieve is to point out that if the comment about hyphenation limits is meant to be taken seriously, you must adjust the values of \lefthyphenmin and \righthyphenmin. OTOH, if you are happy with \lefthyphenmin4 and \righthyphenmin4, you should update the comment. – Mico Nov 2 '15 at 20:52

The puthesis class completely redefines the way the captions work. While adding the setspace package to the preamble solves the problem, other issues arise.

My suggestion is to define the \@makecaption macro to suit your needs and provide a consistent float caption. By adding

\makeatletter
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1 #2}%
\renewcommand{\baselinestretch}{1.0}\reset@font
\ifdim \wd\@tempboxa >\hsize
#1 #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\makeatother


to your preamble you have the same caption for both tables and figures. The above definition (apart from the resetting of \baselinestretch) was taken directly from report.cls, the base class of puthesis.

• Thanks. This does fix the spacing of the captions. However, it also shrinks the row size on many (not all) of the tables. How do I keep the tables themselves from messing up? – Daniel Nov 2 '15 at 20:48
• @Daniel: Can you provide a minimal example replicating this problem? – Werner Nov 2 '15 at 20:55
• If I put \usepackage{setspace} in the code above, just under "subfigure", the rows in the sample table shrink. – Daniel Nov 2 '15 at 21:10
• @Daniel: When I remove all the settings related to the caption package that you've used I get the appropriate single-spaced \caption for both figure and table. See this paste. – Werner Nov 2 '15 at 21:27
• I noticed that when I remove \caption entirely, the table caption number (i.e. "Table #.#" pops up to the line above the rest of the caption. Also, if I shorten the table caption so that it is less than one line long, it is not centered. Is there a way to keep the caption number from popping up, and to keep the caption centered if it is less than one line? – Daniel Nov 2 '15 at 21:40