I am trying to create a command that works in mathmode which simulates a strikeout diagonally while leaving the math display intact.
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\strikeout}[1]{%
\ifmmode%
\tikz[inner sep=0.5pt,baseline] \node [strike out,draw=OrangeRed,anchor=text]{$#1$};%
\else%
\tikz[inner sep=0.5pt,baseline] \node [strike out,draw=OrangeRed,anchor=text]{#1};%
\fi%
}
\begin{document}
$\dfrac{x^2\times 10^3}
{x^2\strikeout{\times 10^3}}$
$\dfrac{x^2\times 10^3}
{x^2\tikzmark{matha}\times 10^3\tikzmark{mathb}}$
\tikz[remember picture, overlay,OrangeRed]
{\draw ($(matha)+(0.1em,-0.125em)$) --
($(mathb)+(-0.1em,0.825em)$);}
$\dfrac{x^2\times 10^3}
{x^2\tikzmark{matha}\times 10^3\tikzmark{mathb}}$
\tikz[remember picture, overlay,OrangeRed,baseline]
{\draw[anchor=text] (matha.south west) --
(mathb.north east);}
\end{document}
Note the discrepancies in the displays. The first does not maintain the mathmode
. Note I want this to work for any scenario thus I was thinking of redefining the strikeout
command I have by using remember picture, overlay
. But note my problem is to get to the line to be drawn like the original strikeout
command. The second code seems to do the trick but it is fixed and am trying to make a user friendly command and well the third, its just out of the question. Thus, I am looking for a suitable way to make a command usable and with the results desired.
cancel
, right?cancel
package has the same effect as mystrikeout
command.$\dfrac{x^2\times 10^3}{x^2\strikeout{{}\times 10^3}}$
(using your definition)? BTW: I'm missing\usetikzlibrary{shapes.misc}
in your code to compile.