7

By default equation numbers produced with the equation environment are put in round brackets. I want to get rid of these on the equation line as well as when referencing. karlkoeller gave a solution for this on this post (this solution requires amsmath).

But this fails when citing with \cref from the cleveref package while \autoref and the default \ref work as expected. See the MWE below.

How can this issue be solved? Or is it wiser to just switch to \autoref?

MWE

\documentclass{scrreprt}
\usepackage{mathtools}
\usepackage{hyperref}
\usepackage{cleveref}

% see: https://tex.stackexchange.com/questions/228448/removing-the-brackets-around-equation-numbering
\makeatletter
\renewcommand\tagform@[1]{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\makeatother
%=====================================================
\begin{document}
foo
\begin{equation}
1+1=2
\label{eq:foo}
\end{equation}
Something is shown in \cref{eq:foo}. Also in \autoref{eq:foo}. And in equation \ref{eq:foo}.
\end{document}
11

Using \creflabelformat as follows

\creflabelformat{equation}{#2\textup{#1}#3}

helps.

creflabelformat

\documentclass{scrreprt}
\usepackage{mathtools}
\usepackage{hyperref}
\usepackage{cleveref}

% see: https://tex.stackexchange.com/questions/228448/removing-the-brackets-around-equation-numbering
\makeatletter
\renewcommand\tagform@[1]{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\makeatother

\creflabelformat{equation}{#2\textup{#1}#3}

\begin{document}
foo
\begin{equation}
1+1=2
\label{eq:foo}
\end{equation}
Something is shown in \cref{eq:foo}. Also in \autoref{eq:foo}. And in equation \ref{eq:foo}.
\end{document}

Thanks to Mico for mentioning in the comments that you should consider using \textup{} to ensure an upright font for the references.

3
  • This removes the brackets as wanted, but it also removes the hyperlink. Is there a way to keep the link? – Enno Jun 3 '17 at 15:56
  • Excellent, that was an easy fix – Enno Jun 3 '17 at 15:59
  • Executing \creflabelformat{equation}{#2#1#3} fails to adhere to an important typographic convention, viz., that equation numbers should always be typeset in upright ("roman") mode even if the surrounding text material is typeset in italics. Better to execute \creflabelformat{equation}{#2\textup{#1}#3}. – Mico Jun 3 '17 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.