Cancelar expresión matemática con una flecha hacia abajo

Cancelar expresión matemática con una flecha hacia abajo

La siguiente soluciónhaciapreguntadonde se va a cancelar algún texto de matemáticas hace uso del cancelpaquete. Allí, la macro \canceltoproduce una flecha desde abajo a la izquierda hacia arriba a la derecha. También proporciona una macro llamada \bcancelque tacha desde la parte superior izquierda hasta la parte inferior derecha.

¿Es posible tener una macro que combine estos dos, algo así como \bcancelto: una flecha de arriba a la izquierda a abajo a la derecha?

Aquí hay un MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}

\begin{document}
\noindent
\verb|\cancel{5y}|:
\[ x+\cancel{5y}=0\]
\verb|\bcancel{5y}|:
\[ x+\bcancel{5y}=0\]
\verb|\xcancel{5y}|:
\[ x+\xcancel{5y}=0\]
\verb|\cancelto{\infty}{5y}|:
\[ x+\cancelto{\infty}{5y}=0\]

\end{document}

Respuesta1

Lo introduzco \bcancelto{label}{term}modificando una de las rutinas de los paquetes. EDITADO para admitir etiquetas en \bcancelto.

La modificación de \canto@vectorproducir \cantox@vectorequivalía a tres cosas:

1) agregar un -antes #4en la \vectorconvocatoria;

2) Cambiar el ^superíndice a un _subíndice antes de \raise; y

3) agregar un -letrero antes de #2seguir el \raise.

Luego tuve que definir \bcanceltohacer esta macro sustitución e invocar \canceltocon la sustitución implementada.

\documentclass{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}
\makeatletter
% #1, #2 offset of label   #6 extra width to clear arrowhead
% #3, #4 vector direction  #7 superscript label style
% #5 vector width          #8 superscript label
\def\cantox@vector#1#2#3#4#5#6#7#8{%
  \[email protected]\p@
  \setbox\z@\vbox{\boxmaxdepth.5\p@
   \hbox{\kern-1.2\p@\kern#1\dimen@$#7{#8}\m@th$}}%
  \ifx\canto@fil\hidewidth  \wd\z@\z@ \else \kern-#6\unitlength \fi
  \ooalign{%
    \canto@fil$\m@th \CancelColor
    \vcenter{\hbox{\dimen@#6\unitlength \kern\dimen@
      \multiply\dimen@#4\divide\dimen@#3 \vrule\@depth\dimen@\@width\z@
      \vector(#3,-#4){#5}%
    }}_{\raise-#2\dimen@\copy\z@\kern-\scriptspace}$%
    \canto@fil \cr
    \hfil \box\@tempboxa \kern\wd\z@ \hfil \cr}}
\def\bcancelto#1#2{\let\canto@vector\cantox@vector\cancelto{#1}{#2}}
\makeatother
\begin{document}
\noindent
\verb|\cancel{5y}|:
\[ x+\cancel{5y}=0\]
\verb|\bcancel{5y}|:
\[ x+\bcancel{5y}=0\]
\verb|\xcancel{5y}|:
\[ x+\xcancel{5y}=0\]
\verb|\cancelto{\infty}{5y}|:
\[ x+\cancelto{\infty}{5y}=0\]
\noindent NEW! \verb|\bcancelto{\infty}{5y}|:
\[ x+\bcancelto{\infty}{5y}=0\]
\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

Aquí hay una solución TikZ.

\documentclass[varwidth,border=50]{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[strike out,-latex,#1]  (N.south west) -- (N.north east);
}}
\newcommand{\bcancelto}[3][]{\tikz[baseline=(N.base)]{
  \node[main node](N){$#2$};
  \node[label node,#1, anchor=north west] at (N.south east){$#3$};
  \draw[strike out,-latex,#1]  (N.north west) -- (N.south east);
}}

\begin{document}
  \cancelto[orange]{test}{Oooo!}
    and math
  $\sqrt{\cancelto[red]{x}{\infty}}$

  \bcancelto[orange]{test}{Oooo!}
    and math
  $\sqrt{\bcancelto[red]{x}{\infty}}$
\end{document}

ingrese la descripción de la imagen aquí

información relacionada