2022 年 6 月版本中对文本大小写和 LaTeX 内核的更改影响了大写字幕

2022 年 6 月版本中对文本大小写和 LaTeX 内核的更改影响了大写字幕

随着2022 年 6 月发布在 LaTeX 中,大小写转换命令以前由textcase已被吸收到内核中,如ltnews35,第 4 页。这一变化的结果是,用于添加例外情况的补丁textcase不再起作用。例如,

\patchcmd{\@uclcnotmath}{\@nonchangecase\ref}{\@nonchangecase\ref\@nonchangecase\eqref}{}{}

当在大写设置(例如大写标题)中使用宏时,不再是抑制amsmath宏参数中大小写变化的解决方案。\eqref

此外,当\label将 放在大写的 参数中时,新版本会出现错误\caption

本文阐述了我更新到2022 年 6 月发布:

\documentclass[11pt]{article}

\usepackage{amsmath,caption,textcase}% need backward compatibility with old textcase

\DeclareCaptionLabelFormat{uppercase}{\MakeTextUppercase{#1} #2}
\DeclareCaptionTextFormat{uppercase}{\MakeTextUppercase{#1}}
\captionsetup[figure]{labelformat=uppercase,textformat=uppercase}

\usepackage{hyperref}
\hypersetup{%
    pdfborder={0 0 0},% 
    colorlinks=true,
}

% This patch added \eqref to the textcase exception list in the previous release
\usepackage{etoolbox}
\makeatletter
    \patchcmd{\@uclcnotmath}{\@nonchangecase\ref}{\@nonchangecase\ref\@nonchangecase\eqref}{}{} 
\makeatother

\begin{document}
\section{Section one}
\begin{equation}
S = k \ln w \label{eqn:1}
\end{equation}
See eqn.~\eqref{eqn:1} and Fig.~\ref{fig:1}.

\begin{figure}
% The first version does not work.  
%       first, the argument of \eqref is capitalized; 
%       second, \label throws errors when it is inside the caption
  \caption{A table caption, eqn.~\eqref{eqn:1}, $z = y^2$\label{fig:1}}

% This works, but requires two changes that might not be obvious to end users of the package involved
%  \caption{A table caption, eqn.~(\ref{eqn:1}), $z = y^2$}\label{fig:1}  
\end{figure}

\listoffigures
\end{document}

类似的修补还允许在先前代码的例外列表中添加脚注。

我非常感激有关在类文件中解决这些问题的建议,以便类的最终用户在编写文档时不必处理这些细节。

答案1

此问题应在发布版本中修复

LaTeX2e <2022-06-01> patch level 4

LaTeX 的。

此外,还可以将新命令添加到防止大小写更改的命令列表中。

 \AddToNoCaseChangeList{ \eqref }

相当于

\ExplSyntaxOn
\tl_put_right:Nn \l_text_case_exclude_arg_tl  { \eqref }
\ExplSyntaxOff

下面并将\eqref(大概来自amsmath)添加到列表中。


原始答案

这很有效,虽然我不建议你在课堂上这样做,但我们会进行一些调整,这样就没有必要了……

\documentclass[11pt]{article}

\usepackage{amsmath,caption}% need backward compatibility with old textcase

\DeclareCaptionLabelFormat{uppercase}{\MakeUppercase{#1} #2}
\DeclareCaptionTextFormat{uppercase}{\MakeUppercase{#1}}
\captionsetup[figure]{labelformat=uppercase,textformat=uppercase}

\makeatletter
\DeclareRobustCommand{\MakeUppercase}[1]{{%
      \def\i{I}\def\j{J}%
      \def\reserved@a##1##2{\let##1##2\reserved@a}%
      \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
\begingroup
\def\label##1{\unexpanded{\label{##1}}}%
\def\eqref##1{\unexpanded{\eqref{##1}}}%
      \protected@edef\reserved@a{\endgroup
   \@expl@text@uppercase@@n{\noexpand\unexpanded{#1}}}%
      \reserved@a
   }}
\makeatother
\ExplSyntaxOn
\tl_put_right:Nn \l_text_case_exclude_arg_tl  { \eqref }
\ExplSyntaxOff
\usepackage{hyperref}
\hypersetup{%
    pdfborder={0 0 0},% 
    colorlinks=true,
}

% This patch added \eqref to the textcase exception list in the previous release

\begin{document}
\section{Section one}
\begin{equation}
S = k \ln w \label{eqn:1}
\end{equation}
See eqn.~\eqref{eqn:1} and Fig.~\ref{fig:1}.

\begin{figure}
% The first version does not work.  
%       first, the argument of \eqref is capitalized; 
%       second, \label throws errors when it is inside the caption
  \caption{A table caption, eqn.~\eqref{eqn:1}, $z = y^2$\label{fig:1}}

% This works, but requires two changes that might not be obvious to end users of the package involved
%  \caption{A table caption, eqn.~(\ref{eqn:1}), $z = y^2$}\label{fig:1}  
\end{figure}

\listoffigures
\end{document}

相关内容