在带有 sn-mathphys-ay 类的表格环境中使用标题会给出重复的相同标识符警告(ext4):(name{table.1})

在带有 sn-mathphys-ay 类的表格环境中使用标题会给出重复的相同标识符警告(ext4):(name{table.1})

我正在使用 Springer 的 sn-mathphys-ay 类。当使用没有标题的表格时,它会编译而不会发出警告,但当使用标题时,它会给出错误

警告(ext4):具有相同标识符的目标(名称{表格1}) 已被使用,重复项被忽略

我已经尝试了针对同一问题提出的所有解决方案,其中要么是 name{page.1} 或 name{figure.1} 或其他,而不是 name{桌子.1} 报告了这个问题,但没有任何效果。我查看了一篇帖子,似乎说类文件中有一个错误,应该使用包 tabularray 来重新定义表环境。这里:tblr 标题无法与 Springer Nature 配合使用。我正在寻找一个更简单的解决方案,没有 tabularray 包和所有必要的其他命令,如上面的帖子。我删除了下面与我的 MWE 不相关的所有其他代码行。编译这个会出现上述重复错误,但这里是表格1名称。删除\caption{Some functions}但保持\label{TableEB}\ref{TableEB}命令,删除标题并将表格计数器设置为 1,并显示对表 1 的正确引用,但无标题显示这是表 1,它编译没有上述警告是关于表格名称重复的。标题是导致此问题的原因,或者至少我认为是,因为我已将其归结为此问题。

任何帮助将不胜感激如何解决使用\caption没有重复的名称 桌子.1.

这是我的 MWE:

\RequirePackage{amsthm} %% Put the amsthm package before fixes a bug also here
\documentclass[pdflatex,sn-mathphys-ay]{sn-jnl}% Math and Phys author-year class
\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%
\usepackage{anyfontsize}% Fixes a bug with font size
\begin{document}
\section{Introduction}\label{sec1}

This is table \ref{TableEB}:

\begin{table}[tbp]\caption{Some functions}\label{TableEB}
\begin{tabular}{ccc}
\toprule $x$ & $y$ & $z$ \\
\midrule $x^2$ & $y^3$ & $z-\sqrt{z}+e^z$ \\
\botrule
\end{tabular}
\end{table}
\end{document}

下面是使用(有编译错误)和不使用(没有编译错误)命令的输出,\caption{Some functions}其余部分保持不变:

使用 \caption

不带 \caption

答案1

这个类有很多问题,例如依赖于包定义的宏,而包本身却不是加载。

这里的问题是,类加载hyperref,并在你的序言中algorithm加载float应该加载的包 hyperref

快速修复:float之前加载\documentclass

\RequirePackage{float}
\documentclass[pdflatex]{sn-jnl}% Math and Phys author-year class
\usepackage{amsmath}%  necessary for the class to work
\usepackage{xcolor}%   necessary for the class to work
\usepackage{manyfoot}% necessary for the class to work
\usepackage{algorithm}%
%\usepackage{algorithmicx}% 
\usepackage{algpseudocode}% loads algorithmicx
\begin{document}
\section{Introduction}\label{sec1}

This is table \ref{TableEB}:

\begin{table}[tbp]\caption{Some functions}\label{TableEB}
\begin{tabular}{ccc}
\toprule $x$ & $y$ & $z$ \\
\midrule $x^2$ & $y^3$ & $z-\sqrt{z}+e^z$ \\
\botrule
\end{tabular}
\end{table}
\end{document}

相关内容