In How use cleveref to get theorem-like name and list item number? the answer provides a way to cause \cref
links to cite the numbers of items within an unnumbered theorem-like environment. It uses enumitem
, among other things.
The example given there is as follows, but with one minor modification here such as I need: the actual item labels have additional formatting specified by the label
key, namely, \setlist[problemsenum,1]{...}
command, namely:
label=\bfseries\sffamily\arabic*.
Unfortunately, this causes the corresponding \cref
links also to include that formatting (bold, sans-serif, and followed by a period).
Is there a way of removing that additional formatting in the links?
The source, with my modification of that label
key, is:
\documentclass[oneside]{book}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{enumitem}
\usepackage[colorlinks,linkcolor=blue]{hyperref} % hyperref added
\usepackage{aliascnt}
\usepackage[nameinlink]{cleveref}
\declaretheoremstyle[
headformat=\NAME\NOTE,
]{probs}
\declaretheorem[
name=PROBLEMS,
style=probs,
]{problemsinner}
\newenvironment{problems}
{\problemsinner Solve these problems.}
{\endproblemsinner}
\newlist{problemsenum}{enumerate}{1}
\setlist[problemsenum,1]{label=\bfseries\sffamily\arabic*.} % label mod here}
\makeatletter
\renewcommand{\p@problemsenumi}{\maybe@thechapter{\thechapter}}
\protected\def\maybe@thechapter#1{%
\ifnum#1=\value{chapter}%
\else
#1.%
\fi
}
\makeatother
\crefformat{problemsenumi}{#2Problem~#1#3}
\Crefformat{problemsenumi}{#2Problem~#1#3}
\crefformat{problemsinner}{#2#3}
\Crefformat{problemsinner}{#2#3}
\begin{document}
\chapter{First}\label{chap:1}
See \cref{prob-part:first-problem} in a different chapter.
\chapter{Second}\label{chap:2}
Refer to \cref{prob-part:first-problem} in this chapter.
\begin{problems}
\label{prob:my-problems}
\begin{problemsenum}
\item \label{prob-part:first-problem}
First problem.
\item
Second problem.
\end{problemsenum}
\end{problems}
\end{document}
As this part of an output page shows, in the link "Problem 2.1.", there is an unwanted period after "2.1", and both the "1" and the period are in bold sans-serif. I want no period there and normal text, not bold or sans-serif.