几年前基于 KOMAscript 的模板需要进行一些更新,因为版本和兼容性已经发生了变化(例如,filecontents
不再需要额外的包等)。在此过程中,我尝试摆脱警告和/或 KOMAscript 中已有功能的包。float
并且caption
是最后要抵制的包。
要求如下
- 想要摆脱浮动 [H](
float
使用该包的唯一原因) - 表格/图片下方左对齐标题
- 可选地,可能会有一些关于表格/图形来源的注释,包括
\cite
表格/图形和标题之间的注释 - ListOf 中的链接应该指向表格/图片,标题本身才有用
以下是基于 caption/float 版本的代码:
\documentclass{scrartcl}
\setkomafont{captionlabel}{\bfseries}
\usepackage{lipsum}
\usepackage{float}
\usepackage[
singlelinecheck=false,
]{caption}
\usepackage[
backend=biber,
citestyle=authoryear,
]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@Book{Mittal2013,
title = {Netcentric System of Systems Engineering with DEVS Unified Process},
author = {Mittal, Saurabh and Martín, José L. R.},
publisher = {CRC Press},
year = {2013},
series = {System of systems engineering},
isbn = {978-1-4398-2707-9},
}
\end{filecontents}
\usepackage[
hidelinks,
breaklinks=true
]{hyperref}
\hypersetup{
bookmarksopen=true,
bookmarksopenlevel=3,
bookmarksnumbered=true,
linktoc=all,
}
\begin{document}
\listoftables
\newpage
\lipsum[1-4]
\begin{table}[H]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\textbf{Category} & \textbf{Diagram type} \\
\hline
Structure diagrams & Class diagrams \\ \cline{2-2}
& Component diagrams \\ \cline{2-2}
& Object diagrams \\ \cline{2-2}
& Composite structure diagrams \\ \cline{2-2}
& Deployment diagrams \\ \cline{2-2}
& Package diagrams \\ \hline
Behavior diagrams & Activity diagrams \\ \cline{2-2}
& Use case diagrams \\ \cline{2-2}
& State diagrams \\ \hline
Interaction diagrams & Sequence diagrams \\ \cline{2-2}
& Collaboration diagrams \\ \cline{2-2}
& Interaction overview diagrams \\ \cline{2-2}
& Timing diagrams \\ \hline
\end{tabular}
\captionbelow*{Based on \protect\cite[p.~11]{Mittal2013}}
\captionbelow[UML diagram types]{UML diagram types\\ \lipsum[1-1]}
\end{center}
\end{table}
\lipsum[5-5]
\cleardoublepage
\newpage
\printbibliography
\end{document}
下面是尝试实现相同功能的代码,但仅使用 KOMAscript:
\documentclass[
captions=nooneline,
]{scrartcl}
\usepackage{lipsum}
\usepackage[
backend=biber,
citestyle=authoryear,
]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@Book{Mittal2013,
title = {Netcentric System of Systems Engineering with DEVS Unified Process},
author = {Mittal, Saurabh and Martín, José L. R.},
publisher = {CRC Press},
year = {2013},
series = {System of systems engineering},
isbn = {978-1-4398-2707-9},
}
\end{filecontents}
\usepackage[
hidelinks,
breaklinks=true
]{hyperref}
\hypersetup{
bookmarksopen=true,
bookmarksopenlevel=3,
bookmarksnumbered=true,
linktoc=all,
}
\begin{document}
\listoftables
\newpage
\lipsum[1-4]
\begin{minipage}{\textwidth}
\begin{center}
\begin{tabular}{|l|l|}
\hline
\textbf{Category} & \textbf{Diagram type} \\
\hline
Structure diagrams & Class diagrams \\ \cline{2-2}
& Component diagrams \\ \cline{2-2}
& Object diagrams \\ \cline{2-2}
& Composite structure diagrams \\ \cline{2-2}
& Deployment diagrams \\ \cline{2-2}
& Package diagrams \\ \hline
Behavior diagrams & Activity diagrams \\ \cline{2-2}
& Use case diagrams \\ \cline{2-2}
& State diagrams \\ \hline
Interaction diagrams & Sequence diagrams \\ \cline{2-2}
& Collaboration diagrams \\ \cline{2-2}
& Interaction overview diagrams \\ \cline{2-2}
& Timing diagrams \\ \hline
\end{tabular}
\end{center}
Based on \cite[p.~11]{Mittal2013}
\captionbelowof{table}[UML diagram types]{UML diagram types\\ \lipsum[1-1]}
\end{minipage}
\lipsum[5-5]
\cleardoublepage
\newpage
\printbibliography
\end{document}
它基本上可以工作,但链接指向标题而不是表格。