Using the Cleveref
package (v0.19) i have a problem with missing parentheses when referencing to subequations, using the \labelcref
command. Here is a MWE:
\documentclass{article}
\usepackage{parskip}
\usepackage{amsmath}
\usepackage{cleveref}
% Change so that the parentheses for equations are part of the hyperlink
\creflabelformat{equation}{#2(#1)#3}
\crefrangelabelformat{equation}{#3(#1)#4 to #5(#2)#6}
% This does not work:
\creflabelformat{subequations}{#2(#1)#3}
\crefrangelabelformat{subequations}{#3(#1)#4 to #5(#2)#6}
\begin{document}
\textbf{Writing three subequations:}
\begin{subequations}\label{eqn:abc}
\begin{align}
A&=B\label{eqn:abc1}\\
B&=C\label{eqn:abc2}\\
C&=A\label{eqn:abc3}
\end{align}
\end{subequations}
Referencing using \texttt{$\backslash$cref}: \cref{eqn:abc}, \cref{eqn:abc1}, \cref{eqn:abc2}, \cref{eqn:abc3}.
Referencing using \texttt{$\backslash$labelcref}: \labelcref{eqn:abc}, \labelcref{eqn:abc1}, \labelcref{eqn:abc2}, \labelcref{eqn:abc3}. $\leftarrow$ Parenthesis are missing for subequations!\\[2ex]
\textbf{Writing two separate single equations:}
\begin{equation}\label{eqn:singlexy}
x=y
\end{equation}
and
\begin{equation}\label{eqn:singleyx}
y=x
\end{equation}
Referencing using \texttt{$\backslash$cref}: \cref{eqn:singlexy}, \cref{eqn:singleyx}.
Referencing using \texttt{$\backslash$labelcref}: \labelcref{eqn:singlexy}, \labelcref{eqn:singleyx}. $\leftarrow$ Parenthesis are \emph{not} missing for normal equations!
\end{document}
The output is as follows:
As can be seen, the \labelcref
command omits the parentheses when referencing to the subequations (1a, 1b and 1c), as well as to their parent equation (1). As mentioned in the code above, the following lines of code do not solve the problem:
\creflabelformat{subequations}{#2(#1)#3}
\crefrangelabelformat{subequations}{#3(#1)#4 to #5(#2)#6}
I'm quite certain it worked in an earlier version of Cleveref (without adding the above two lines).
Any ideas would be greatly appreciated!
Best Answer
You are right, in version 0.18.9 the parenthesis were there.
In the latest version, additional support for
subequations
has been added. So says the documentation:First of all, you have to use
subequation
instead ofsubequations
and, for them,\labelcrefformat
instead of\creflabelformat
and\labelcrefrangeformat
instead of\crefrangelabelformat
, that isinstead of
MWE:
Output:
Strangely enough, for
equation
s you have to use\creflabelformat
and\crefrangelabelformat
.