Captions are only centered if they are shorter than one line:
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete `demo` option in actual document
\begin{document}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45]{mmm1mbiff}
\caption{short}
\label{fig:short}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45]{mmm1mbiff}
\caption{this one is so long that it does not fit into a single line any more so it spans two lines}
\label{fig:long}
\end{figure}
\end{document}
What's more: line breaks are not natively supported:
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete `demo` option in actual document
\begin{document}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45]{mmm1mbiff}
\caption{I want this to\\ be two lines}
\label{fig:error}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45]{mmm1mbiff}
\caption{I want this to\newline be two lines}
\label{fig:vanish}
\end{figure}
\end{document}
However, the caption package supports line breaks in captions. If the complete caption is short enough (and the option
singlelinecheck=on
is active which is the default) they even are centered without any further setup as long as you use
\\
and
not \newline
:
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete `demo` option in actual document
\usepackage{caption}
\begin{document}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45]{mmm1mbiff}
\caption{I want this to\\ be two lines}
\label{fig:works}
\end{figure}
\end{document}
In your original code this does not work, because the caption is too long and the lines are left-aligned. However, caption has a solution for this, too:
\captionsetup{justification=centering}
. You can use this for all captions by placing it in the preamble or for one caption only by placing it in the
{figure}
environment where you want this:
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete `demo` option in actual document
\usepackage{caption}
\captionsetup{justification=centering}
\newcommand*\picsource[1]{\textit{#1}}
\begin{document}
\begin{figure}[]
\centering
\includegraphics[scale=0.45]{mm,m1,mb,iff}
\caption{%
Interesting rates during the crisis \\
\picsource{Source: authors graph based on FRED data}}
\label{mmm1iff}
\end{figure}
\end{document}
In this code I also replaced the
\textit
with a semantically more meaningful command.
Regards