
다음과 같은 해결책~로질문일부 수학 텍스트가 취소되는 곳에서는 패키지를 사용합니다 cancel
. 매크로는 \cancelto
왼쪽 아래에서 오른쪽 위로 화살표를 생성합니다. 또한 \bcancel
왼쪽 상단에서 오른쪽 하단으로 삼진을 제공하는 매크로도 제공합니다 .
\bcancelto
이 두 가지를 함께 결합하는 매크로 (왼쪽 상단에서 오른쪽 하단으로 화살표) 를 갖는 것이 가능합니까 ?
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}
답변1
\bcancelto{label}{term}
패키지 루틴 중 하나를 수정하여 소개합니다 . 에서 라벨을 지원하도록 편집되었습니다 \bcancelto
.
\canto@vector
생산을 위한 수정은 \cantox@vector
다음 세 가지로 이루어졌습니다.
1) 호출 에 -
이전을 추가합니다 .#4
\vector
2) 위 첨자를 아래 첨자 ^
로 변경합니다 . 그리고_
\raise
3) 다음을 따르기 -
전에 기호를 추가합니다 .#2
\raise
그런 다음 이 매크로 대체를 정의 하고 대체가 있는 위치에서 \bcancelto
호출해야 했습니다.\cancelto
\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}
답변2
다음은 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}