How to remove the dot in the cross-reference to an item from enumerate?
Closed this issue · 4 comments
When I refer to an item in a enumerate list, there is an annoying dot in the sentence. Please see more details in my MWE.
I find some discussions about this but still couldn't solve it. See, for example, https://tex.stackexchange.com/q/288407/104838 and https://tex.stackexchange.com/q/234499/104838
MWE with Version 2020/08/04 v4.0.5 ElegantBook document class:
\documentclass[en]{elegantbook}
\begin{document}
\begin{problemset}\label{set:1}
\item\label{itm:1_1}
Problem 1
\item Problem 2
\end{problemset}
Problem~\ref{itm:1_1} is quite easy!
\end{document}
You need to redefine the problemset
environment, which the source code section references to
Lines 715 to 721 in 78fe2c7
You need to use the ability to set
label
and ref
separately in the enumitem
package
\documentclass[en]{elegantbook}
\renewenvironment{problemset}[1][\chaptername~\problemsetname]{
\begin{center}
\phantomsection\addcontentsline{toc}{section}{\texorpdfstring{\chaptername\;\problemsetname}{\problemsetname}}
\textcolor{structurecolor}{\Large\bfseries\adftripleflourishleft~#1~\adftripleflourishright}
\end{center}
\begin{enumerate}[label=\color{structurecolor}\arabic*., ref=\arabic*]}{
\end{enumerate}}
\begin{document}
\begin{problemset}\label{set:1}
\item\label{itm:1_1}
Problem 1
\item Problem 2
\end{problemset}
Problem~\ref{itm:1_1} is quite easy!
\end{document}
Thanks for your help!
It works in the pdf output! But I receive the following error message:
mwe-cross-reference-item.tex|12 error| Undefined control sequence. \problemsetname
mwe-cross-reference-item.tex|12 error| Undefined control sequence. \chaptername \;\problemsetname
mwe-cross-reference-item.tex|12 error| Undefined control sequence. ...left ~\chaptername ~\problemsetname
I made a mistake. Your version is v4.x
, and the code I gave is v3.11
, and the code corresponding to v4.x
is referred to
Lines 829 to 837 in f123c6a
modified into
\documentclass[en]{elegantbook}
\renewenvironment{problemset}[1][\chaptername~\chapterextra\exercisename]{
\begin{center}
\phantomsection\addcontentsline{toc}{section}{\texorpdfstring{\chaptername\;\exercisename}{\exercisename}}
% \markboth{#1}{\rightmark}
\markright{#1}
\textcolor{structurecolor}{\Large\bfseries\adftripleflourishleft~#1~\adftripleflourishright}
\end{center}
\begin{enumerate}[label=\color{structurecolor}\arabic*., ref=\arabic*]}{
\end{enumerate}}
\begin{document}
\begin{problemset}\label{set:1}
\item\label{itm:1_1}
Problem 1
\item Problem 2
\end{problemset}
Problem~\ref{itm:1_1} is quite easy!
\end{document}
PS: It is not recommended to use the v4.x
version because it is still in development
This works like a charm! Your solution is greatly appreciated!