9

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}
1

1 Answer 1

15

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, 2017 at 15:56
  • 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, 2017 at 16:00
  • 3
    Note, for anyone else coming across this in 2021, the creflabelformat solution now retains links, so should be considered preferable, in my view.
    – Noldorin
    Jul 30, 2021 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .