
我正在急切地尋找一種方法,使文檔中的所有表格具有相同的標題,該標題通過caption[title]{long description...}
.原因是我的表源自 R (xtable),每次重新計算它們時它都使用上述格式,我無法更改它。所以不幸的是我無法使用任何不同的解決方案。這對我來說非常重要,因為我的文件中有很多表格。
這是一個 MWE。正如您所看到的,標題丟失了,只有標籤可見。較長描述中的縮排是故意的。
編輯:
我做了一張圖來更好地說明這一點:
\documentclass[a4paper, 12pt, headsepline, smallheadings]{scrreprt}
\usepackage[labelfont={small,bf}, textfont=small, labelsep=colon,singlelinecheck=false,format=plain, parindent=1em]{caption}
\newlength\myindention
\DeclareCaptionFormat{myformat}%
{#1#2\\\hspace*{\myindention}#3}
\setlength\myindention{1em}
\captionsetup{format=myformat}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\begin{document}
\listoftables
\chapter{Introduction}
\begin{table}[h]
\caption[title table 1]{description table 1}
\fbox{content}
\end{table}
\begin{table}[h]
\caption[title table 2]{description table 2}
\fbox{content}
\end{table}
\end{document}
謝謝你的幫忙。最好的問候,湯姆。
答案1
如果您確定所有字幕都採用這種格式,請在序言中添加以下行:
\let\oldcaption\caption
\renewcommand*\caption[2][]{%
\oldcaption[#1]{#1\\\hspace*{\myindention}#2}%
}
並刪除以下內容
\DeclareCaptionFormat{myformat}%
{#1#2\\\hspace*{\myindention}#3}
\captionsetup{format=myformat}
你應該實現你想要的。
微量元素
\documentclass[a4paper, 12pt, headsepline, smallheadings]{scrreprt}
\usepackage[labelfont={small,bf}, textfont=small, labelsep=colon,singlelinecheck=false,format=plain, parindent=1em]{caption}
\newlength\myindention
\setlength\myindention{1em}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\let\oldcaption\caption
\renewcommand*\caption[2][]{%
\oldcaption[#1]{#1\\\hspace*{\myindention}#2}%
}
\begin{document}
\listoftables
\chapter{Introduction}
\begin{table}[h]
\caption[title table 1]{description table 1}
\fbox{content}
\end{table}
\begin{table}[h]
\caption[title table 2]{description table 2}
\fbox{content}
\end{table}
\end{document}
輸出: