3

I'm looking to strikethrough a cross-reference generated with \cref. I thought a basic example like the following would work:

\documentclass{article}
\usepackage{cleveref}
\usepackage{soul}

\begin{document}

Consider
\begin{equation}\label{eq:int}
\int_a^bf(t)dt=0    
\end{equation}

Then \st{Ignore \cref{eq:int}.}

\end{document}

However, I get an error message about one-too-many } symbols. To clarify, I would like the cross-reference to still be present (and blue, but I don't think that's important to this example), but have the strikethrough on top of it.

Any help would be appreciated.

  • 4
    Similar problems have already showed up; the simplest workaround is \st{Ignore \mbox{\cref{eq:int}}.} – egreg Oct 19 '18 at 9:26
2

This is a by-pass solution with TikZ, striking out the text by overprinting with a line, using a node aligned to the baseline and applying the west and east node anchors as drawing start and end points.

Using TikZ styles and/or pgfkeys etc. the customization would even better.

\documentclass{article}
\usepackage{cleveref}

\usepackage{tikz}


\newcommand{\tikzst}[2][line width=1pt,blue,opacity=0.4]{%
  \tikz[baseline]{ \node[anchor=text,outer sep=0pt,inner sep=0pt] (A) {#2}; \draw[#1] ([xshift=-0.1ex]A.west) --  ([xshift=0.1ex]A.east);}%
}

\begin{document}

Consider
\begin{equation}\label{eq:int}
\int_a^bf(t)dt=0    
\end{equation}

\begin{equation}
  c^2 = a^{2} + b^{2} \label{eq:pythagoras}
\end{equation}

Then \tikzst{Ignore \cref{eq:int}}, but think of \tikzst[red]{\cref{eq:pythagoras}}!

\end{document}

enter image description here

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.