`\\` 什麼時候不在 `\caption` 中另起一行?

`\\` 什麼時候不在 `\caption` 中另起一行?

使用命令在為什麼在標題中使用參數時會加倍?,它在大多數情況下都有效,但在少數情況下(例如 20 例中有 1 例)\\不會開始新行。

例如使用

\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
... & ... & ... & ... & ... & ...
%...
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{\Lt{Weisspunkte}}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{\cite[S.~279]{poynton_digital_2012}\index{Illuminant}}}
\end{table}

在表格中之前不開始新行Quelle,如下所示(請參見黃線;頁面其餘部分進行像素化以強調重要部分並提高圖像壓縮): 範例頁面中的外觀

或詳細顯示:

詳細資訊:未插入換行符

請注意,同一命令會在表上圖中的「Bildquelle:」之前插入換行符號。我找不到類似問題的參考;如果頁面上的垂直空間很緊張,LaTeX 是否會嘗試避免換行?

補充內容

對於那些未能找到的人\\,這裡是(來自參考文獻的答案):

\newcommand{\FS}[2][Bildquelle]{%
  \protect\ifthenelse{\equal{#1}{}}%
    {\protect\\{\protect\scriptsize{}#2}}
    {\protect\\{\protect\scriptsize{}#1: #2}}}

強製表 6.1 在新頁面上並沒有改變行為。使標題文字更長或更短也不會改變行為。但是當我將標題更改為

\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{\Lt{Weisspunkte}}Lorem ipsum Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{\cite[S.~279]{poynton_digital_2012}\index{Illuminant}}}

然後表格轉到下一頁,並插入換行符:

正確的標題為“Lorem ipsum”

微量元素

最後我成功創建了一個MWE(pdflatex,實際上比預期容易):

\documentclass[a4paper,twoside]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
\usepackage[pdftex,colorlinks,hypertexnames=false]{hyperref}
\usepackage{makeidx}
\usepackage{showidx}
\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}{%
\protect\\*{\protect\scriptsize{}#2}}{%
\protect\\*{\protect\scriptsize{}#1: #2}}}
\begin{document}
%
\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
A & B & C & D & E & F \\
A & B & C & D & E & F \\
A & B & C & D & E & F \\
A & B & C & D & E & F \\
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{Weisspunkte}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{[Poy12, S.~279]\index{Illuminant}}}
\end{table}
%
\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
A & B & C & D & E & F \\
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{Weisspunkte2}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{[Poy12, S.~279]\index{Illuminant}}}
\end{table}
\end{document}

好像: MWE 輸出的一部分

解決方案(https://tex.stackexchange.com/a/518731/182650

添加後

\usepackage[font=small,labelfont={sf,bf},position=bottom,singlelinecheck=false]%
{caption}

MWE 的結果看起來像這樣,這對我來說沒問題。 在此輸入影像描述

答案1

在此輸入影像描述

您可以簡化範例:

\documentclass[a4paper,twoside]{report}

\begin{document}
\begin{table}
\caption[]{aaaaaaaaaaa aaaaaa
ccccccccccccccc bbbbbbbbbbbbbbb \\ 
dddddddddddddd}
\end{table}
%
\begin{table}

\caption[]{aaaaa\\bbb}
\end{table}
\end{document}

大多數類別以兩種樣式設定標題,第一種基本上是在\mbox單行中,如果它適合文字框,則該行居中(並且\\在 mbox 中不執行任何操作)。如果該框太寬而無法容納在一行中,則會將其丟棄,並且在 中重新設定標題\parbox,如果使用第二種格式\\將起作用。

caption軟體包有一個選項可以跳過單行測試(如果您想要這樣做的話)。

相關內容