我正在尝试再次使用我在 2019 年提出的这个问题的答案(放错了 \noalign。在 memoir \legend 命令中使用 \captionsetup 时,\captionsetup ->\noalign) 使用Tex Live 2022,但答案中的代码不再编译:
\documentclass[12pt,a4paper,twoside]{memoir}
\usepackage{caption}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{ragged2e}
\RequirePackage{ltablex}\keepXColumns
\makeatletter
\renewcommand{\legend}[2][var]{%
\M@gettitle{#2}%
\memlegendinfo{#2}%
\par
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\setlength{\belowcaptionskip}{4pt}%
\caption@setlabelseparator{colon}%
\@makecaption{#1}{\ignorespaces #2}\par
\endgroup}
\makeatother
\DeclareCaptionLabelSeparator{barr}{~\textendash~}
\captionsetup{format=hang,labelseparator=barr,}
\begin{document}
\begin{tabularx}{\linewidth}{>{\RaggedRight}p{3cm}|>{\arraybackslash}X}
\hline
\multicolumn{2}{p{\dimexpr\textwidth-2\tabcolsep\relax}}{\legend{O autor}}
\endlastfoot
Cor & Branco \\ \hline
\end{tabularx}
\begin{table}[htb]
\caption{Something}
\begin{tabular}{p{2.6cm}p{6.0cm}}
Meta & Paradigma \\
\end{tabular}
\legend{Something}
\end{table}
\end{document}
它说:
(/usr/share/texlive/texmf-dist/tex/latex/caption/ltcaption.sty)
./main.tex:34: Undefined control sequence.
\\legend ...skip }{4pt}\caption@setlabelseparator
{colon}\@makecaption {#1}{...
l.34 \end{tabularx}
?
\captiondelim{:~}
在我的最终文档中也是一起使用的\caption@setlabelseparator{colon}
,现在仅使用\captiondelim{:~}
错误变成:
(/usr/share/texlive/texmf-dist/tex/latex/caption/ltcaption.sty)
./main.tex:34: Misplaced \noalign.
\captionsetup ->\noalign
\bgroup \@ifstar \@captionsetup \@captionsetup
l.34 \end{tabularx}
?
如果我删除这两者\caption@setlabelseparator{colon}
,\captiondelim{:~}
PDF 可以正常编译,但它在各处都使用破折号,而对于我的模板,它需要在命令中使用冒号:
而不是破折号:--
\legend
更新至 TexLive 2022 后\captiondelim{:~}
我该如何继续使用?\caption@setlabelseparator{colon}
答案1
在提交时https://gitlab.com/axelsommerfeldt/caption/-/commit/a9a968f976865fd617f4f431e5b4b2ebdd0b0882?page=4#791450f831b92438f900ff0b01fbce50725be9f7_680_654在更改文件时caption3.sty
,命令\caption@setlabelseparator{colon}
被重命名为\caption@set{labelseparator}{colon}
,因此我修复了包的新旧版本的代码:
\ifdefined\caption@setlabelseparator
\caption@setlabelseparator{colon}%
\else
\caption@set{labelseparator}{colon}%
\fi