TeX - LaTeX Asked on March 31, 2021
I would like to customise the way multiple references are handled in the cleveref
package. I would like to have the form (eq0, eq1, eq3, eq4)
, ie comma separated, unless the set of references form a complete range, in which case I would like an en-dash, eg (eq0--eq3)
instead of (eq0, eq1, eq2, eq3)
.
However, I do not use the begin{equation} ... end{equation}
environment. I use the following macro: newcommand{nt}{addtocounter{equation}{1}tag{theequation}}
and begin{equation*} ... nt end{equation*}
. If it were only equations, I could just swap to using the non-*
-d version. However, there are other reasons why I wish to persist with that nt
macro.
Below is a minimal working example. (Apologies that it is quite long, but it is as short as I could get!)
documentclass[]{article}
usepackage{amsmath,cleveref}
newcommand{nt}{refstepcounter{equation}tag{theequation}}
crefformat{equation}{(#2#1#3)}
crefmultiformat{equation}{(#2#1#3}{, #2#1#3)}{, #2#1#3}{, #2#1#3)}
crefrangeformat{equation}{(#3#1#4--#5#2#6)}
begin{document}
setcounter{equation}{-1}
begin{equation}label{0} 0end{equation}
begin{equation}label{1} 1end{equation}
begin{equation}label{2} 2end{equation}
begin{equation}label{3} 3end{equation}
begin{equation}label{4} 4end{equation}
begin{equation*}ntlabel{5} 5end{equation*}
begin{equation*}ntlabel{6} 6end{equation*}
begin{equation*}ntlabel{7} 7end{equation*}
begin{equation*}ntlabel{8} 8end{equation*}
begin{equation*}ntlabel{9} 9end{equation*}
texttt{textbackslash cref{0,1,3,4}}: cref{0,1,3,4}
%this prints the desired `(0, 1, 3, 4)`
texttt{textbackslash cref{5,6,8,9}}: cref{5,6,8,9}
%this prints the undesired `(5--9)`
end{document}
It seems that cleveref
somehow does not know that this is not a full range when I use the nt
macro. Maybe it’s something to do with cleveref
looking at the environment, rather than the counter?
Edit.
Mico appeared to suggest using refstepcounter
and placing nt
before label
. They did not give further details, but I made the changes above anyway.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP