我有以下代码
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{4}
\begin{minipage}[h!]{0\linewidth}
\text{Let:} \end{minipage}
&& G_{\delta_r}^{\beta} &= \frac{n_1 s + n_0}{s^2 + d_1 s + d_0} = \frac{0.01956 s + 7.01}{s^2 + 0.802 s + 6.489} \\
&& step \left(G_{\delta_r}^{\beta}(s) \right) = \frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0} \\
\\
% \left[
% \makebox[0\linewidth][s] {
% \begin{dcases}
\makebox[0\linewidth][s]{Expanding with partial fractions:} \\
&& \frac{x_1}{s} + \frac{x_{21}s + x_{20}}{s^2 + d_1 s + d_0} &= \frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0} \\
\\
\makebox[0\linewidth][s]{Removing denominator:} \\
&& x_1(s^2 + d_1 s + d_0) + s(x_{21} s + x_{20}) &= n_1 s + n_0 \\
\\
\makebox[0\linewidth][s]{Has solutions:} \\
\makebox[0\linewidth][s]{
\begin{minipage}[h!]{0.3\linewidth} \centering
$x_{21} = \frac{-n_0}{d_0} = -1.08$ \end{minipage}
\begin{minipage}[h!]{0.3\linewidth} \centering
$x_1 = \frac{n_0}{d_0} = 1.08$ \end{minipage}
\begin{minipage}[h!]{0.3\linewidth} \centering
$x_{20} = n_1 - \frac{n_0 d_1}{d_0} = -0.847$ \end{minipage} }
% \end{dcases}
% }
\\
\begin{minipage}[h!]{0\linewidth}
\text{Hence:} \end{minipage}
&& \frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{s^2 + 0.8-2s + 6.489} \\
\\
\makebox[0\linewidth][s]{Completing the square:} \\
&& \frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{(s + 0.401)^2 + 6.328} \\
\makebox[0\linewidth][s]{Inverse Laplace:} \\
&& \mathcal{L}^{-1}\left\{ \frac{G_{\delta_r}^{\beta}(s)}{s} \right\} &= 1.08 - e^{-.401t} \left(1.08 \cos(t\sqrt{6.328}) + \frac{0.847}{\sqrt{6.328}} \sin(t\sqrt{6.328}) \right)
\end{alignat*}
\end{document}
其结果为:
我想放置一个如图所示的框(或某种括号)来表示“子计算”。复杂之处在于,该框需要跨越多行方程和 alignat 环境的多列。
我尝试了很多方法,包括\makebox
,,\minipage
\bcases,
\matrix
有什么建议么?
答案1
\parbox
在a 内部使用 a ,\fcolorbox
在 a 内部使用 a \makebox
,并在 内部使用整个构造\intertext
;对原始标记做了一些更改(特别是代码被大大简化),但保留了框前后表达式的原始对齐方式:
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark}
\begin{document}
Let:
\begin{align*}
G_{\delta_r}^{\beta} &= \frac{n_1 s + n_0}{s^2 + d_1 s + d_0} = \frac{0.01956 s + 7.01}{s^2 + 0.802 s + 6.489} \\
\text{step} \left(G_{\delta_r}^{\beta}(s) \right) = \frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0}
\intertext{%
\makebox[\linewidth][c]{\fcolorbox{blue}{white}{\parbox{\linewidth}{%
Expanding with partial fractions:
\[
\frac{x_1}{s} + \frac{x_{21}s + x_{20}}{s^2 + d_1 s + d_0} =
\frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0}
\]
Removing denominator:
\[
x_1(s^2 + d_1 s + d_0) + s(x_{21} s + x_{20}) = n_1 s + n_0
\]
Has solutions:
\[
x_{21} = \frac{-n_0}{d_0} = -1.08\qquad
x_1 = \frac{n_0}{d_0} = 1.08\qquad
x_{20} = n_1 - \frac{n_0 d_1}{d_0} = -0.847
\]
Hence:}}}
}
\frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{s^2 + 0.8-2s + 6.489} \\
\shortintertext{Completing the square:}
\frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{(s + 0.401)^2 + 6.328} \\
\shortintertext{Inverse Laplace:}
\mathcal{L}^{-1}\left\{ \frac{G_{\delta_r}^{\beta}(s)}{s} \right\} &= 1.08 - e^{-.401t} \left(1.08 \cos\alpha + \frac{0.847}{\sqrt{6.328}} \sin\alpha \right),
\end{align*}
where $\alpha=t\sqrt{6.328}$.
\end{document}
另一个选择是使用tikzmark
库;其思想是使用\tikzmark
在适当的位置放置标记,然后使用这些标记绘制蓝色矩形。下面我展示了这种方法,并说明了标记的另一种选择(当然,这种方法也适用于上述方法或任何其他变体):
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark}
\begin{document}
Let:
\begin{align*}
G_{\delta_r}^{\beta} &= \frac{n_1 s + n_0}{s^2 + d_1 s + d_0} = \frac{0.01956 s + 7.01}{s^2 + 0.802 s + 6.489} \\
\text{step} \left(G_{\delta_r}^{\beta}(s) \right) = \frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0}
\end{align*}
\tikzmark{start}Expanding with partial fractions:
\[
\frac{x_1}{s} + \frac{x_{21}s + x_{20}}{s^2 + d_1 s + d_0} =
\frac{1}{s} \cdot \frac{n_1 s + n_0}{s^2 + d_1 s + d_0}
\]
Removing denominator:
\[
x_1(s^2 + d_1 s + d_0) + s(x_{21} s + x_{20}) = n_1 s + n_0
\]
Has solutions:
\[
x_{21} = \frac{-n_0}{d_0} = -1.08\qquad
x_1 = \frac{n_0}{d_0} = 1.08\qquad
x_{20} = n_1 - \frac{n_0 d_1}{d_0} = -0.847\tikzmark{end}
\]
Hence:
\begin{align*}
\frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{s^2 + 0.8-2s + 6.489} \\
\shortintertext{Completing the square:}
\frac{G_{\delta_r}^{\beta}(s)}{s} &= \frac{1.08}{s} - \frac{1.08s + 0.847}{(s + 0.401)^2 + 6.328} \\
\shortintertext{Inverse Laplace:}
\mathcal{L}^{-1}\left\{ \frac{G_{\delta_r}^{\beta}(s)}{s} \right\} &= 1.08 - e^{-.401t} \left(1.08 \cos(t\sqrt{6.328}) + \frac{0.847}{\sqrt{6.328}} \sin(t\sqrt{6.328}) \right)
\end{align*}
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1.5pt,blue]
([xshift=-1ex,yshift=2.5ex]current page text area.west|-{pic cs:start})
rectangle
([yshift=-2.5ex]current page text area.east|-{pic cs:end});
\end{tikzpicture}
\end{document}