TransWikia.com

Suppress section number, keep label

TeX - LaTeX Asked on June 19, 2021

I’m looking for a simple way to use label and section* simultaneously. My goal is to have an unnumbered section with a label to be able to autoref it.

The problem is: label does not work when using section*. Of course, it does work when using section, but then the section is numbered.

I am have the following in a document:

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

EDIT:

I’m using this template from Overleaf: https://www.overleaf.com/latex/templates/template-for-data-descriptor-submissions-to-scientific-data/ygdzkjcqzmbp

I’m looking for a simple way to use label and section* simultaneously with this template.

The problem must be in the "wlscirep.cls" file because this stand-alone code works just fine:

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}

But hyperref[sec:crit]{Criterion~ref*{sec:crit}} doesn’t work when it’s in that template.


One Answer

Adding phantomsection above section*{Criterion} label{sec:crit} works.

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}

Correct answer by SP1 on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP