I am trying to use the solution offered by Kpym in this topic.
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{environ}
\usepackage{fancyhdr}
\usepackage{tasks}
\pagestyle{empty}
\tikzstyle{fancytitle3}=[draw=black, fill=white, text=black, rounded corners = 3pt, inner sep = 3]
\NewEnviron{sol}{%
\begin{center}
\begin{tikzpicture}
\node[rectangle, rounded corners = 7pt, inner sep = 10 ,minimum width=0.9\textwidth,
text opacity=1,
draw=orange, ultra thick, draw opacity=1,
fill=white, fill opacity=1] (box)
{%
\begin{minipage}{.95\textwidth}
\begin{small}\textsl{\BODY}\end{small}
\end{minipage}
};
\node[fancytitle3, right=5pt] at (box.north west) {\textsl{\textbf{\begin{small}Solution \end{small}} }};
\end{tikzpicture}
\end{center}
}
\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}
\begin{align*}
\text{This is good:}\qquad \cancelto[red]{2x-1}{1}
\end{align*}
\begin{sol}
\begin{align*}
\text{We don't want this:}\qquad \cancelto[red]{2x-1}{1}
\end{align*}
\end{sol}
\end{document}
As you can see, when I use the \cancelto
inside the solution environment, something is telling tex to stretch the arrow and I'm not sure what is causing it.
I am aware of the cancel
package, which doesn't exhibit this problem. At this stage, I am more interested in whether current situation can be mended.
tikzpicture
environments, which is a no-no... Thesol
environemnt uses puts its content within atikzpicture
and then the\cancelto
invokes anothertikzpicture
(via the\tikz
).