我发现这有助于平息我的问题带着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 width
for\[...\]
才能工作。这可以通过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}