amsart 图形标题与 TeXlive 2021

amsart 图形标题与 TeXlive 2021

在使用 TeXlive 2021 和 amsart 时,我发现图片标题未对齐。测试文件在这里:

\documentclass{amsart}
\begin{document}

\hbox to\hsize{X\hfil \TeX{Live} 2021 on Mac\hfil X}

\begin{figure}[h]
\hbox to\hsize{X\hfil X\hfil X}
\caption{XXXXX}
\end{figure}
\end{document}

第一个 hbox 只是为了显示边距。在 Macosx 11.6 上使用 TeXlive 2021(2021 年 6 月)运行时,标题未居中: TeXlive 2021 输出

但是,在 Ubuntu 20.04 上使用 TeXlive 2019 运行时,居中是正确的: TeXlive 2019 输出 我检查过 amsart.cls 中与图形标题相关的部分在这些版本之间没有变化。此外,使用 latex 还是 pdflatex 没有任何区别。问题只发生在一行内适合的标题上。

这是我可以轻松访问的仅有的两个 TeXlive 版本。

答案1

原始文件在 LaTeX 版本中运行无错误

LaTeX2e <2021-11-15> pre-release-2 (develop 2021-9-20 branch)

原始答案

该课程需要针对 2021 年 Latex 版本进行更新,需要额外的 unkern

更新实际上,我们可能会对 latex 格式进行调整,因此在下一个 latex 版本发布后,以下补丁将不再需要 https://github.com/latex3/latex2e/pull/671

在此处输入图片描述

\documentclass{amsart}
\makeatletter
\long\def\@makecaption#1#2{%
  \setbox\@tempboxa\vbox{\color@setgroup
    \advance\hsize-2\captionindent\noindent
    \@captionfont\@captionheadfont#1\@xp\@ifnotempty\@xp
        {\@cdr#2\@nil}{.\@captionfont\upshape\enspace#2}%
    \unskip\kern-2\captionindent\par
    \global\setbox\@ne\lastbox\color@endgroup}%
  \ifhbox\@ne % the normal case
    \setbox\@ne\hbox{\unhbox\@ne\unskip\unskip\unpenalty\unkern\unkern}%
                                                               %%%%%%% extra unkern
  \fi
  \ifdim\wd\@tempboxa=\z@ % this means caption will fit on one line
    \setbox\@ne\hbox to\columnwidth{\hss\kern-2\captionindent\box\@ne\hss}%
  \else % tempboxa contained more than one line
    \setbox\@ne\vbox{\unvbox\@tempboxa\parskip\z@skip
        \noindent\unhbox\@ne\advance\hsize-2\captionindent\par}%
  \fi
  \ifnum\@tempcnta<64 % if the float IS a figure...
    \addvspace\abovecaptionskip
    \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
  \else % if the float IS NOT a figure...
    \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
    \nobreak
    \vskip\belowcaptionskip
  \fi
\relax
}
\makeatother
\begin{document}

\hbox to\hsize{X\hfil \TeX{Live} 2021 on Mac\hfil X}

\begin{figure}[h]
\hbox to\hsize{X\hfil X\hfil X}
\caption{XXXXX}
\end{figure}
\end{document}

相关内容