Tikz 变体取消至

Tikz 变体取消至

我发现有助于平息我的问题带着cancel包裹的箭头但displaymath似乎把它弄坏了。

我使用的链接代码的唯一部分是

\usepackage{tikz}
\usepackage{relsize}
\usetikzlibrary{calc}
\newcommand\canceltoSwNe[2]{%                                                   
  \begin{tikzpicture}[baseline = (B.base)]
    \node[anchor = center, inner sep = 0pt] (B) {#1};
    \draw[arrows = {}-{latex}]%                                                 
    ($(B.south west)+(-1pt, -1pt)$) -- ($(B.north east)+(+4pt, +1pt)$)%         
    node [anchor = south west, xshift = +1pt, yshift = -1pt,%                   
    inner sep = 0pt]%                                                           
    {\smaller\smaller{#2}};
  \end{tikzpicture}%                                                            
}

如果此代码能够固有其所使用的环境,那就太好了。就我而言,就是环境align。但是,它没有,我必须插入数学分隔符。如果我使用\(\),一切都会正常,但不成比例,因为这是用于内联数学的。我尝试使用,\[\]但它反而会崩溃。

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

\usepackage{tikz}
\usepackage{relsize}
\usetikzlibrary{calc}
\newcommand\canceltoSwNe[2]{%                                                   
  \begin{tikzpicture}[baseline = (B.base)]
    \node[anchor = center, inner sep = 0pt] (B) {#1};
    \draw[arrows = {}-{latex}]%                                                 
    ($(B.south west)+(-1pt, -1pt)$) -- ($(B.north east)+(+4pt, +1pt)$)%         
    node [anchor = south west, xshift = +1pt, yshift = -1pt,%                   
    inner sep = 0pt]%                                                           
    {\smaller\smaller{#2}};
  \end{tikzpicture}%                                                            
}
\begin{document}
\begin{align*}
  L\{2\cos(3t)\}(s)
   & = 2\int_0^{\infty}\cos(3t)e^{-st}dt\\
   & = \canceltoSwNe{\(\frac{2e^{-st}\sin(3t)}{3}\biggl|_0^{\infty}\)}{\(0\)} +
   \frac{s}{3}\int_0^{\infty}\sin(3t)e^{-st}dt
\end{align*}
\begin{align*}
  L\{2\cos(3t)\}(s)
   & = 2\int_0^{\infty}\cos(3t)e^{-st}dt\\
   & = \canceltoSwNe{\[\frac{2e^{-st}\sin(3t)}{3}\biggl|_0^{\infty}\]}{\[0\]} +
   \frac{s}{3}\int_0^{\infty}\sin(3t)e^{-st}dt
\end{align*}
\end{document}

在此处输入图片描述

答案1

您需要指定text widthfor\[...\]才能工作。这可以通过varwidth包来完成以模拟minipage/parbox模式。

\documentclass{article}
\usepackage[makeroom]{cancel}
\usepackage{mathtools}
\usepackage{varwidth}

\usepackage{tikz}
\tikzset{block/.style = {anchor = center, inner sep = 0pt,
                          execute at begin node={\begin{varwidth}{0.5\linewidth}},  %% change 0.5 as you wish
                          execute at end node={\end{varwidth}}
                          }
   }

\usepackage{relsize}
\usetikzlibrary{calc}
\newcommand\canceltoSwNe[2]{%
  \begin{tikzpicture}[baseline = (B.base)]
    \node[block] (B) {#1};
    \draw[arrows = {}-{latex}]%
    ($(B.south west)+(-1pt, -1pt)$) -- ($(B.north east)+(+4pt, +1pt)$)%
    node [anchor = south west, xshift = +1pt, yshift = -1pt,%
    inner sep = 0pt]%
    {\smaller\smaller{#2}};
  \end{tikzpicture}%
}
\begin{document}
\begin{align*}
  L\{2\cos(3t)\}(s)
   & = 2\int_0^{\infty}\cos(3t)e^{-st}dt\\
   & = \canceltoSwNe{\(\frac{2e^{-st}\sin(3t)}{3}\biggl|_0^{\infty}\)}{\(0\)} +
   \frac{s}{3}\int_0^{\infty}\sin(3t)e^{-st}dt
\end{align*}
\begin{align*}
  L\{2\cos(3t)\}(s)
   & = 2\int_0^{\infty}\cos(3t)e^{-st}dt\\
   & = \canceltoSwNe{\[\frac{2e^{-st}\sin(3t)}{3}\biggl|_0^{\infty}\]}{0} +
   \frac{s}{3}\int_0^{\infty}\sin(3t)e^{-st}dt
\end{align*}
\end{document}

在此处输入图片描述

相关内容