我有下图及其相应的标题:
如您所见,标题不恰当地断行了,我想避免这种情况。最好不要简单地减小标题文本的字体大小。
代码如下:
\documentclass[12pt, a4paper] {article}
\usepackage[skip=10pt, labelfont=bf, labelsep=space]{caption}
\usepackage{tikz}
\usepackage[numbers,sort,authoryear]{natbib}
\hypersetup{hidelinks=true}
\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}
感谢您的帮助!
答案1
一些评论:
由于您 (i) 使用
agsm
与引文管理包一起分发的参考书目样式,harvard
并且 (ii) 加载natbib
包而不是harvard
包,因此您也应该加载包。正如其名称所示,它将包定义的各种宏(在 中使用)har2nat
“翻译”为等效宏。harvard
agsm.bst
natbib
您目前正在
natbib
使用选项numbers
、sort
和加载包authoryear
。您应该删除前两个选项:该agsm
样式适用于作者年份样式的引文标注 - 尝试将其与数字样式的引文标注一起使用是毫无意义的;sort
只有当是标注样式时,该选项才有意义numbers
。现在回到你的查询要点:你应该将
\caption
命令写为\caption{Time Line for an Event Study \citep[p.~157]{campbell1996}}
请注意 (“tie”) 字符的使用
~
,其作用类似于牢不可破的空格字符。两个小问题:(i)
\label
指令应该后指令\caption
——特别是当您希望能够在文档的其他位置交叉引用图形时。(ii)使用\begin{center}...\end{center}
会增加很多(垂直)空白;请\centering
改用指令。
\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",
address = "Princeton NJ",
}
\end{filecontents}
\usepackage[skip=10pt, labelfont=bf, labelsep=space]{caption}
\usepackage{tikz}
\usepackage[authoryear]{natbib}
\usepackage{har2nat}
\usepackage{hyperref}
\hypersetup{hidelinks=true}
\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}