![在 captionsetup 中使用宽度时,longtable 会出现不需要的标题缩进](https://linux22.com/image/365678/%E5%9C%A8%20captionsetup%20%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%AE%BD%E5%BA%A6%E6%97%B6%EF%BC%8Clongtable%20%E4%BC%9A%E5%87%BA%E7%8E%B0%E4%B8%8D%E9%9C%80%E8%A6%81%E7%9A%84%E6%A0%87%E9%A2%98%E7%BC%A9%E8%BF%9B.png)
如果我width=0.9\linewidth
在 中使用,我会得到一个缩进的标题captionsetup
。然后longtable
标题会居中或缩进,并且没有办法让它与表格左对齐。但是,width
在其他表格上工作正常。我使用它是因为我的文档中的一些标题很长,但我不想让它们一直延伸到文档的右边距。我曾尝试margin
在 中使用captionsetup
,但这会导致同样的问题。我也尝试在 captionsetup 中使用负缩进设置,但这只会影响标题的第二行,而不会影响表格编号。
\documentclass[12pt, a4paper]{memoir}
\usepackage{longtable}
\usepackage{csquotes}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{threeparttable} % for table notes
\usepackage{threeparttablex} % for longtable notes
\usepackage{caption}
\usepackage{siunitx} % align numbers by decimal point
\usepackage{lipsum}
%setup page
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\setulmargins{3.5cm}{*}{*} % sets start of text on page after ruled header
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{2cm}{*}{*} % start of rule header line on page
\setlrmarginsandblock{3.5cm}{2.5cm}{*} % left and right margins
\checkandfixthelayout
\sisetup{detect-family, add-integer-zero = false, group-digits = false}%
%adding width indents/centers longtable caption
\captionsetup[table]{textfont=it, justification=raggedright, singlelinecheck=off, format=plain, labelsep=newline, skip=5pt, width=0.9\linewidth}
%excluding width works
%\captionsetup[longtable]{justification=raggedright, labelsep=newline, singlelinecheck=off, textfont=it, skip=5pt, format=plain}
\begin{document}
%normal table
\begin{table}[!htb]
\begin{threeparttable}
\caption{Evaluation of some contexts based on some coordinates}
\label{some_tabel1}
\begin{tabularx}{\textwidth}{%
X
r
p{1mm}
p{20mm}
S[table-format=2.0, table-column-width=12mm]
S[table-format=2.0, table-column-width=12mm]
S[table-format=2.0, table-column-width=12mm]
S[table-format=2.0, table-column-width=12mm]
}
\toprule
\multirow{2}[2]{*}{Sample context}
& \multirow{2}[2]{*}{\textit{N}}
&
& \multirow{2}[2]{1.8cm}{Proposed construct}
& \multicolumn{2}{c}{Some location}
& \multicolumn{2}{c}{Another location} \\
\cmidrule(r){5-6}
\cmidrule(l){7-8}
& & & & \multicolumn{1}{c}{\textit{n}}
& \multicolumn{1}{c}{\%}
& \multicolumn{1}{c}{\textit{n}}
& \multicolumn{1}{c}{\%} \\
\midrule
Item 1 & $54$ && Low & 23 & 43 & 31 & 57 \\
Item 2 & $73$ && High & 60 & 82 & 13 & 18 \\
Item 3 & $80$ && High & 72 & 90 & 8 & 10 \\
Item 4 & $83$ && Medium & 72 & 87 & 11 & 13 \\
Item 5 & $159$ && Rare & 148 & 93 & 11 & 7 \\
\bottomrule
\end{tabularx}
\begin{tablenotes}[para,flushleft]
\small{\textit{Note}. Some further notes here.}
\end{tablenotes}
\end{threeparttable}
\end{table}
%longtable
\begin{ThreePartTable}
\begin{TableNotes}[para,flushleft]
\small{\textit{Note}. Some note text here.}
\end{TableNotes}
\setlength{\extrarowheight}{2mm} %add row padding before midrule
\begin{longtable}[!htb]{
>{\raggedright}p{0.5cm}
>{\raggedright}p{3.1cm}
>{\raggedright}p{8.5cm}
p{1.5cm}
}
\caption[]{Severity of identified problems and proposed changes}
\label{some_lable2}\\
\toprule
\\ [-1.8\normalbaselineskip]
\multicolumn{2}{l}{Change} & Justification & Severity\\ %the first header
\midrule
\endfirsthead
\caption{Severity of identified problems and proposed changes (cont.)}\\
\toprule
\\ [-1.8\normalbaselineskip]
\multicolumn{2}{l}{Change} & Justification & Severity\\ %the following header(s)
\midrule
\endhead
\midrule
\\[-1.8\normalbaselineskip]
\multicolumn{4}{r}{\textit{continued}}
\endfoot
\\[-1\normalbaselineskip]
\bottomrule
\insertTableNotes
\endlastfoot
1. & Bullet point 1 and some extra sample text & \lipsum[1] & High \\
2. & Bullet point 2 & \lipsum[2] & Medium\\
3. & Bullet point 3 & \lipsum[3] & Low\\
\end{longtable}
\end{ThreePartTable}
\end{document}