答案1
\overbrace
编写一些表现为/ 的东西并不难,\underbrace
但它会有同样的缺点:你需要额外的括号才能获得正确的间距。
\documentclass{article}
\usepackage{mathtools} % for \abs
\DeclarePairedDelimiter{\abs}{|}{|}
\newcommand*{\descbox}[1]{%
\mathop{\boxed{#1}}\limits
}
\begin{document}
Without extra braces:
\[
\frac{d\phi}{dt}
= - R_{\mathit{wdg}} \descbox{\frac{1+\abs{\frac{\phi}{\beta}}^S}{L_u}}_{i_L(\phi)}
- R_{\mathit{wdg}}
\descbox{
\frac{\descbox{\frac{1+\abs{\frac{\alpha}{\beta}}^S}{L_u}\alpha}^{k(\alpha)}\dot\alpha}% num
{\dot\phi}%den
}_{i_E(\phi,\dot\phi)}
+u(t)
\]
With extra braces:
\[
\frac{d\phi}{dt}
= - R_{\mathit{wdg}} {\descbox{\frac{1+\abs{\frac{\phi}{\beta}}^S}{L_u}}_{i_L(\phi)}}
- R_{\mathit{wdg}}
{\descbox{
\frac{\descbox{\frac{1+\abs{\frac{\alpha}{\beta}}^S}{L_u}\alpha}^{k(\alpha)}\dot\alpha}% num
{\dot\phi}%den
}_{i_E(\phi,\dot\phi)}}
+u(t)
\]
\end{document}
不过,我猜你会一直使用这个描述框和描述我宁愿定义一个带有两个参数的宏。代码
\documentclass{article}
\usepackage{mathtools} % for \abs
\DeclarePairedDelimiter{\abs}{|}{|}
\makeatletter
\newcommand*{\descbox}{\@ifstar{\let\@tempa\sp\desc@box}{\let\@tempa\sb\desc@box}}
\newcommand*{\desc@box}[2]{%
{\mathop{\boxed{#2}}\limits\@tempa{#1}}%
}
\makeatother
\begin{document}
\[
\frac{d\phi}{dt}
= - R_{\mathit{wdg}} \descbox{i_L(\phi)}{\frac{1+\abs{\frac{\phi}{\beta}}^S}{L_u}}
- R_{\mathit{wdg}}
\descbox{i_E(\phi,\dot\phi)}{
\frac{\descbox*{k(\alpha)}{\frac{1+\abs{\frac{\alpha}{\beta}}^S}{L_u}\alpha}\dot\alpha}% num
{\dot\phi}%den
}
+u(t)
\]
\end{document}
给出的结果与上一个快照中的第二个公式相同。我已定义\descbox
默认将“标签”(第一个参数)放在框下方,而带星号的版本将其放在顶部。您可以通过交换的参数来反转行为\@ufstar
,即定义
\newcommand*{\descbox}{\@ifstar{\let\@tempa\sb\desc@box}{\let\@tempa\sp\desc@box}}