我写信是因为我想在时间线上添加标题。我使用的是 Overleaf。我不确定如何正确地做到这一点(现在我收到错误消息 \caption outside float)...
\begin{chronology}[8]{1890}{1965}{\textwidth}[\textwidth]
\event{1896}{\color{blue}{1896}}
\event[1896]{1921}{\small{Period 1}}
\event{1922}{\color{blue}{1922}}
\event[1922]{1945}{\small{Period 2}}
\event{1946}{\color{blue}{1946}}
\event[1946]{1962}{\small{Period 3}}
\event{1962}{\color{blue}{1962}}
\end{chronology}\caption{Country}
答案1
标题可以在表格或图形等浮动对象内使用。
您可以将放在chronology
这些环境中,但由于您可能希望针对此特定用途进行自定义,因此最好定义一个新环境(此处称为Chronos
)并选择您想要的设置:没有标签或数字,只有带有一些格式的文本。
\documentclass{article}
\usepackage{chronology}
\usepackage{kantlipsum}% only for dummy text
\usepackage{caption} % custom captions
\captionsetup[Chronos]{labelformat=empty,textfont={bf,it} } % only text of the caption, in bold /italic
\usepackage{newfloat} % added <<<<<
\DeclareFloatingEnvironment[placement={h!}]{Chronos} % new float <<<<
\begin{document}
In \emph{Country} the documented events took place during three different periods:
\begin{Chronos}
\caption{Country}
\begin{chronology}[8]{1890}{1965}{\textwidth}[\textwidth]
\event{1896}{\color{blue}{1896}}
\event[1896]{1921}{\small{Period 1}}
\event{1922}{\color{blue}{1922}}
\event[1922]{1945}{\small{Period 2}}
\event{1946}{\color{blue}{1946}}
\event[1946]{1962}{\small{Period 3}}
\event{1962}{\color{blue}{1962}}
\end{chronology}
\end{Chronos}
\kant[2]
\end{document}