抑制部分編號,保留標籤

抑制部分編號,保留標籤

我正在尋找一個簡單的使用方式\label\section*同時進行。我的目標是擁有一個帶標籤的未編號部分能夠做到\autoref這一點。

問題是:\label使用時不起作用\section*。當然,在使用 時它確實有效\section,但隨後該部分已編號。

我在文檔中有以下內容:

\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}
\section*{Criterion} \label{sec:crit}
\section*{My new section}
Blah blah refers to \autoref{sec:crit}

編輯:

我正在使用 Overleaf 中的這個範本:https://www.overleaf.com/latex/templates/template-for-data-descriptor-submissions-to-scientific-data/ygdzkjcqzmbp

我正在尋找一個簡單的使用方式\label\section*與此範本同時使用。

問題一定出在「wlscirep.cls」檔案中,因為這個獨立程式碼運作得很好:

\documentclass[10pt]{article}
\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
\section*{Criterion} \label{sec:crit}
Here is section one
\section*{My new section}
Here is section two. This refers back to \hyperref[sec:crit]{Criterion~\ref*{sec:crit}}.
\end{document}

但當\hyperref[sec:crit]{Criterion~\ref*{sec:crit}}它在該模板中時不起作用。


答案1

添加\phantomsection以上\section*{Criterion} \label{sec:crit}作品。

\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
\phantomsection
\section*{Criterion} \label{sec:crit}
Here is section one
\section*{My new section}
Here is section two. This refers back to \hyperref[sec:crit]{Criterion~\ref*{sec:crit}}.
\end{document}

相關內容