如何通过预定的微小边距来增加 \Blocks 矩形的大小?

如何通过预定的微小边距来增加 \Blocks 矩形的大小?

我想在矩形的上方和下方放置一些边距,但似乎没有\Block简单的选项来实现这一点

在此处输入图片描述

一种解决方案是使用自定义命令,如下所示

\newlength{\heightbigstrut}
\setlength{\heightbigstrut}{3mm}
\newcommand{\bigstrutX}[2][0]{
    \ifthenelse{\equal{#1}{0}}
    % No optional argument is provided
    {\renewcommand{\bigstrutjot}{\heightbigstrut} \bigstrut[#2]}
    % Optional argument provided
    {\renewcommand{\bigstrutjot}{#1} \bigstrut[#2]}
}

这达到了预期的结果,但我认为最好得到一个nicematrix有助于实现类似结果的选项

在此处输入图片描述

\documentclass[aspectratio=169, xcolor={x11names}, t, handout]{beamer}

\usepackage{ifthen}

\usepackage[x11names]{xcolor}

\usetheme{Dresden}
\usefonttheme{professionalfonts}

\newcommand{\phasor}[1]{\mathbf{#1}}
\usepackage{nicematrix}
% BEGIN_FOLD
    
    \newcolumntype{e}{@{{$\mspace{\thinmuskip}$}}c@{{$\mspace{\thinmuskip}$}}}
    
% END_FOLD
\usepackage{booktabs}
% BEGIN_FOLD

    \newcommand{\basmahspace}{\mspace{0.61\thinmuskip}}

% END_FOLD
\usepackage{bigstrut}
% BEGIN_FOLD

    \newlength{\heightbigstrut}
    \setlength{\heightbigstrut}{3mm}
    \newcommand{\bigstrutX}[2][0]{
        \ifthenelse{\equal{#1}{0}}
        % No optional argument is provided
        {\renewcommand{\bigstrutjot}{\heightbigstrut} \bigstrut[#2]}
        % Optional argument provided
        {\renewcommand{\bigstrutjot}{#1} \bigstrut[#2]}
    }

% END_FOLD

% ==========================================================================
% math commands customizations
% BEGIN_FOLD

\newcommand{\cosX}[1]{\cos\left(#1\right)}
\newcommand{\sinX}[1]{\sin\left(#1\right)}
\newcommand{\atan}[1]{\tan^{-1} \left( #1 \right)}
    
% END_FOLD


\begin{document}

\begin{frame}
    
    \begin{equation}
        \begin{NiceArray}{r @{\quad}l @{\quad\quad}>{\thickspace}l@{\thickspace}}
            \alpha > \omega_{0}
            & \text{Overdamped}
            & \Block[draw=Coral3, rounded-corners]{3-1}{}
            v(t) = A_{1} \basmahspace \mathrm{e}^{s_{1} \basmahspace t} + A_{2} \basmahspace \mathrm{e}^{s_{2} \basmahspace t}
            \bigstrutX[0.5mm]{t}
            \\
            \alpha = \omega_{0}
            & \text{Critically Damped}
            & v(t) = (A_{1} + A_{2} \basmahspace t ) \basmahspace \mathrm{e}^{-\alpha \basmahspace t}
            \\
            \alpha < \omega_{0}
            & \text{Underdamped}
            & v(t) = \mathrm{e}^{-\alpha \basmahspace t} \basmahspace (A_{1} \cosX{\omega_{d} \basmahspace t} + A_{2} \sinX{\omega_{d} \basmahspace t})
            \bigstrutX[0.5mm]{b}
            \CodeAfter
            \SubMatrix{\rbrace}{1-2}{3-2}{.}
        \end{NiceArray}
    \end{equation}
    
    \begin{equation}
        \setlength{\arraycolsep}{0pt}
        \everymath{\displaystyle}
        \begin{NiceArray}{e @{}l l@{\thickspace}}
            \Block[draw=Coral3, rounded-corners]{2-3}{}
            Z &= \sqrt{R^{2} + X^{2}} & \quad \text{\alert{magnitude}}
            \bigstrutX[3mm]{t}
            \\
            \theta_{z} &= \atan{\frac{\pm X}{R}} & \quad \text{\alert{angle}} 
            \bigstrutX[3mm]{b}
            \CodeAfter
            \SubMatrix.{1-2}{2-2}\rbrace
        \end{NiceArray}
    \end{equation}
    
\end{frame}

\end{document}

答案1

一种方法是使用NiceMatrix 的cell-space-top-limitcell-space-bottom-limit键,使用命令在第一行和最后一行添加额外空间\RowStyle。这种方法的一个问题是,由于它使单元格变大,\rbrace第二个矩阵中的也会变大,并且会延伸到边缘。因此,您可以使用可选参数和带有较小负值的键\Block来稍微减小尺寸。\SubMatrixextra-height

梅威瑟:

\PassOptionsToPackage{x11names}{xcolor}
\documentclass[aspectratio=169, t, handout]{beamer}
\usepackage{tikz}
\usepackage{ifthen}

\usetheme{Dresden}
\usefonttheme{professionalfonts}

\newcommand{\phasor}[1]{\mathbf{#1}}
\usepackage{nicematrix}
\newcolumntype{e}{@{{$\mspace{\thinmuskip}$}}c@{{$\mspace{\thinmuskip}$}}}
    
\usepackage{booktabs}
\newcommand{\basmahspace}{\mspace{0.61\thinmuskip}}

% ==========================================================================
% math commands customizations
\newcommand{\cosX}[1]{\cos\left(#1\right)}
\newcommand{\sinX}[1]{\sin\left(#1\right)}
\newcommand{\atan}[1]{\tan^{-1} \left( #1 \right)}

\begin{document}

\begin{frame}
    
    \begin{equation}
        \begin{NiceArray}{r @{\quad}l @{\quad\quad}>{\thickspace}l@{\thickspace}}
            \RowStyle[cell-space-top-limit=1mm]{}
            \alpha > \omega_{0}
            & \text{Overdamped}
            & \Block[draw=Coral3, rounded-corners]{3-1}{}
            v(t) = A_{1} \basmahspace \mathrm{e}^{s_{1} \basmahspace t} + A_{2} \basmahspace \mathrm{e}^{s_{2} \basmahspace t}
            \\
            \alpha = \omega_{0}
            & \text{Critically Damped}
            & v(t) = (A_{1} + A_{2} \basmahspace t ) \basmahspace \mathrm{e}^{-\alpha \basmahspace t}
            \\
            \RowStyle[cell-space-bottom-limit=1mm]{}
            \alpha < \omega_{0}
            & \text{Underdamped}
            & v(t) = \mathrm{e}^{-\alpha \basmahspace t} \basmahspace (A_{1} \cosX{\omega_{d} \basmahspace t} + A_{2} \sinX{\omega_{d} \basmahspace t})
            \CodeAfter
            \SubMatrix{\rbrace}{1-2}{3-2}{.}
        \end{NiceArray}
    \end{equation}
    
    \begin{equation}
        \setlength{\arraycolsep}{0pt}
        \everymath{\displaystyle}
        \begin{NiceArray}{e @{}l l@{\thickspace}}
            \RowStyle[cell-space-top-limit=2mm]{}
            \Block[draw=Coral3, rounded-corners]{2-3}{}
            Z &= \sqrt{R^{2} + X^{2}} & \quad \text{\alert{magnitude}}
            \\
            \RowStyle[cell-space-bottom-limit=2mm]{}
            \theta_{z} &= \atan{\frac{\pm X}{R}} & \quad \text{\alert{angle}} 
            \CodeAfter
            \SubMatrix.{1-2}{2-2}\rbrace[extra-height=-3mm]
        \end{NiceArray}
    \end{equation}
    
\end{frame}

\end{document}

结果:

在此处输入图片描述

相关内容