![如何使用直线而不是箭头来输入取消](https://linux22.com/image/458257/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E7%9B%B4%E7%BA%BF%E8%80%8C%E4%B8%8D%E6%98%AF%E7%AE%AD%E5%A4%B4%E6%9D%A5%E8%BE%93%E5%85%A5%E5%8F%96%E6%B6%88.png)
答案1
欢迎来到 Tex.SE!
众多解决方案之一:
\documentclass[varwidth,border=30]{standalone}
\usepackage{tikz}
\tikzset{main node/.style={inner sep=0,outer sep=0},
label node/.style={inner sep=0,outer ysep=.2em,outer xsep=.4em,font=\scriptsize,overlay},
strike out/.style={shorten <=-.2em,shorten >=-.5em,overlay}}
\newcommand{\cancelto}[3][]{\tikz[baseline=(N.base)]{
\node[main node](N){$#2$};
\node[label node,#1, anchor=south west] at (N.north east){$#3$};
\draw[-,#1] (N.south west) -- (N.north east)}}
\begin{document}
\cancelto[purple]{Text}{no!}
and math
$\cancelto[blue]{x^3}{x^2}$
\end{document}
答案2
如果您只是想删除箭头,您可以\canto@vector
使用 patch 来\line
代替\vector
。
\documentclass{article}
\usepackage{xcolor}
\usepackage[Smaller]{cancel}
\usepackage{xpatch}% to patch \cancel
\makeatletter
\xpatchcmd{\canto@vector}{\vector}{\line}{}{}
\makeatother
\renewcommand{\CancelColor}{\color{green!80!red}}
\begin{document}
\[
\cancelto{x^2}{x^3}
\]
\end{document}