[Tex/LaTex] Changing the font spacing in figure/table captions

captionsline-spacing

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}

Best Answer

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.

enter image description here

Related Question