# [Tex/LaTex] Preventing line break in figure caption

captionscitingfloatsline-breakingline-spacing

I have the following figure with the corresponding caption:

As you can see the caption inappropriately breaks the line, which I want to avoid. Optimally without simply reducing the font size of the caption text.

Code as follows:

\documentclass[12pt, a4paper] {article}
\usepackage[skip=10pt, labelfont=bf, labelsep=space]{caption}
\usepackage{tikz}
\usepackage[numbers,sort,authoryear]{natbib}

\begin{document}

\newcommand{\mytab}[1]{%
\begin{tabular}{@{}c@{}}
#1
\end{tabular}
}
\begin{figure} [h!]
\label{fig: timeline}
\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (11,0);
\foreach \x in {0.8,4,5.5,7,10.2}
\draw(\x cm,3pt) -- (\x cm, -3pt);
\draw (0.8,0) node[below=3pt] {$T_0$};
\draw (4,0) node[below=3pt] {$T_1$};
\draw (5.5,0) node[below=3pt] {$0$};
\draw (7,0) node[below=3pt] {$T_2$};
\draw (10.2,0) node[below=3pt] {$T_3$};
\draw (2.35,0) node[above=12pt, align=center] {
$\left(\mytab{estimation \\ window}\right]$};
\draw (5.5,0) node[above=12pt, align=center]{
$\left(\mytab{event \\ window}\right]$};
\draw(8.65,0) node[above=12pt, align=center]{
$\left(\mytab{post-event \\ window}\right]$};
\end{tikzpicture}
\end{center}
\caption{Time Line for an Event Study (\cite{campbell1996}, p. 157})
\end{figure}

\bibliographystyle{agsm}
\bibliography{./references}
\end{document}


• Since you're (i) using the agsm bibliography style, which is distributed with the harvard citation management package and (ii) loading the natbib package rather than the harvard package, you should load the har2nat package as well. As its name indicates, it "translates" various macros that are defined by the harvard package (and which are used in agsm.bst) into equivalent natbib macros.

• You're currently loading the natbib package with the options numbers, sort, and authoryear. You should drop the first two options: The agsm style is meant for authoryear-style citation callouts -- pointless to try to use it with numeric-style citation callouts; the sort option only makes sense if numbers is the callout style.

• Now to the main point of your query: You ought to write the \caption command as

\caption{Time Line for an Event Study \citep[p.~157]{campbell1996}}


Note the use of the ~ ("tie") character, which acts like an unbreakable space character.

• Two minor points: (i) The \label instruction should come after the \caption instruction -- especially if you want to be able to cross-reference the figure elsewhere in the document. (ii) Use of \begin{center}...\end{center} adds a lot of (vertical) whitespace; use the \centering directive instead.

\documentclass[12pt, a4paper]{article}
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@book{campbell1996,
author = "John Y. Campbell and Andrew W. Lo and A. Craig McKinlay",
title  = "The Econometrics of Financial Markets",
year   = 1996,
publisher = "Princeton University Press",
}
\end{filecontents}
\usepackage[skip=10pt, labelfont=bf, labelsep=space]{caption}
\usepackage{tikz}
\usepackage[authoryear]{natbib}
\usepackage{har2nat}
\usepackage{hyperref}

\newcommand{\mytab}[1]{%
\begin{tabular}{@{}c@{}}
#1
\end{tabular}
}

\begin{document}

\begin{figure} [h!]
\centering
\begin{tikzpicture}
\draw (0,0) -- (11,0);
\foreach \x in {0.8,4,5.5,7,10.2}
\draw(\x cm,3pt) -- (\x cm, -3pt);
\draw (0.8,0) node[below=3pt] {$T_0$};
\draw (4,0) node[below=3pt] {$T_1$};
\draw (5.5,0) node[below=3pt] {$0$};
\draw (7,0) node[below=3pt] {$T_2$};
\draw (10.2,0) node[below=3pt] {$T_3$};
\draw (2.35,0) node[above=12pt, align=center] {
$\left(\mytab{estimation \\ window}\right]$};
\draw (5.5,0) node[above=12pt, align=center]{
$\left(\mytab{event \\ window}\right]$};
\draw(8.65,0) node[above=12pt, align=center]{
$\left(\mytab{post-event \\ window}\right]$};
\end{tikzpicture}
\caption{Time Line for an Event Study \protect\citep[p.~157]{campbell1996}}
\label{fig:timeline}
\end{figure}

A cross-reference to \autoref{fig:timeline}.

\bibliographystyle{agsm}
\bibliography{./references}
\end{document}