我正在尝试对齐下表中的括号。通常我使用\eqmakebox
它来获得我想要的结果。但是,当我尝试对齐里面的内容时NiceTabularX
,我收到一条错误消息
扫描使用 __nicematrix_CodeAfter_i:n 时文件结束。
在以下 MWE 中,删除 时\eqmakebox[equalized][r]
,代码运行良好
\documentclass[aspectratio=169]{beamer}
\usetheme{Dresden}
\usepackage{bigstrut}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[3][l]{\eqmakebox[#2][#1]{$\displaystyle\color{black}#3$}}
\usepackage{stackengine}
\usepackage{adjustbox}
\usepackage{nicematrix}
\usepackage{booktabs}
\begin{document}
\begin{frame}[plain]
\begin{description}
\item[Summary of Conversion of Quantities Across Gears]
\end{description}
\renewcommand{\bigstrutjot}{5mm}
\everymath{\displaystyle}
\newlength{\widthWord}
\setlength{\widthWord}{\widthof{Displacement}}
\begin{NiceTabularX}{\textwidth}{>{\bfseries}m[c]{\widthWord} X[3,c, m] X[1, c, m]}
Quantity & Conversion Rule & Notes
\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
\addlinespace[1.2mm]
Torque & \adjustbox{valign=b}{\eqmakebox[equalized][r]{${T_{\mathrm{new}} = T_{\mathrm{old}}}$}
$\left[ \frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}} \right]\phantom{^{2}}$
} & Torque increases with teeth in gears
\\
\addlinespace
\Block[c]{1-1}{Mechanical \\ Impedance} & \adjustbox{valign=b}{\eqmakebox[equalized][r]{$Z_{\mathrm{M, \thinspace new} = Z_{\mathrm{M, \thinspace old}}}$}
$\left[ \bigstrut
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}} \right]^{2}$
} & Mechanical impedance increases with teeth in gears
\\
\addlinespace
\Block[c]{1-1}{Angular \\ Displacement} & \adjustbox{valign=b}{\eqmakebox[equalized][r]{$\theta_{\mathrm{new}} = \theta_{\mathrm{old}}$}
$\left[ \frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}} \right]\phantom{^{2}}$
} & Angular displacement decreases with teeth in gears
\\
\CodeAfter
\SubMatrix.{2-1}{2-1}\}[xshift=1mm]
\SubMatrix.{3-1}{3-1}\}[xshift=1mm]
\SubMatrix.{4-1}{4-1}\}[xshift=1mm]
\end{NiceTabularX}
\end{frame}
\end{document}
答案1
对我有用。我重新格式化了代码以提高可读性,并删除了由于空行导致的错误原因。
我还提出了一个更简单的版本。
\documentclass[aspectratio=169]{beamer}
\usetheme{Dresden}
\usepackage{bigstrut}
\usepackage{eqparbox}
\usepackage{stackengine}
\usepackage{adjustbox}
\usepackage{nicematrix}
\usepackage{booktabs}
\newcommand{\eqmathbox}[3][l]{\eqmakebox[#2][#1]{$\displaystyle\color{black}#3$}}
\newlength{\widthWord}
\newcommand{\splitcell}[1]{\begin{tabular}{c}#1\end{tabular}}
\begin{document}
\begin{frame}[plain]
\begin{description}
\item[Summary of Conversion of Quantities Across Gears]
\end{description}
\renewcommand{\bigstrutjot}{5mm}
\everymath{\displaystyle}
\setlength{\widthWord}{\widthof{Displacement}}
\begin{NiceTabularX}{\textwidth}{>{\bfseries}m[c]{\widthWord} X[3,c, m] X[1, c, m]}
Quantity & Conversion Rule & Notes \\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
\addlinespace[1.2mm]
Torque &
\adjustbox{valign=b}{%
\eqmakebox[equalized][r]{${T_{\mathrm{new}} = T_{\mathrm{old}}}$}
$\left[
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
\right]\phantom{^{2}}$%
} &
Torque increases with teeth in gears
\\
\addlinespace
\Block[c]{1-1}{Mechanical \\ Impedance} &
\adjustbox{valign=b}{%
\eqmakebox[equalized][r]{$Z_{\mathrm{M, \thinspace new} = Z_{\mathrm{M, \thinspace old}}}$}
$\left[ \bigstrut
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
\right]^{2}$%
} &
Mechanical impedance increases with teeth in gears
\\
\addlinespace
\Block[c]{1-1}{Angular \\ Displacement} &
\adjustbox{valign=b}{%
\eqmakebox[equalized][r]{$\theta_{\mathrm{new}} = \theta_{\mathrm{old}}$}
$\left[
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
\right]\phantom{^{2}}$%
} &
Angular displacement decreases with teeth in gears
\\
\CodeAfter
\SubMatrix.{2-1}{2-1}\}[xshift=1mm]
\SubMatrix.{3-1}{3-1}\}[xshift=1mm]
\SubMatrix.{4-1}{4-1}\}[xshift=1mm]
\end{NiceTabularX}
\end{frame}
\begin{frame}[plain]
\begin{description}
\item[Summary of Conversion of Quantities Across Gears]
\end{description}
\begin{NiceTabular*}{\textwidth}{
@{\extracolsep{\fill}}
>{\bfseries}c
>{$\displaystyle}r<{$}
@{\enspace}
>{$\displaystyle}l<{$}
c
@{}
}
Quantity & \multicolumn{2}{c}{Conversion Rule} & Notes \\
\cmidrule(lr){1-1} \cmidrule(lr){2-3} \cmidrule(lr){4-4}
\addlinespace[1.2mm]
Torque &
T_{\mathrm{new}} = T_{\mathrm{old}} &
\left[
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
\right] &
\splitcell{Torque \\ increases with \\ teeth in gears}
\\
\addlinespace
\splitcell{Mechanical \\ Impedance} &
Z_{\mathrm{M, \thinspace new}} = Z_{\mathrm{M, \thinspace old}} &
\left[ \bigstrut
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
\right]^{2} &
\splitcell{Mechanical \\ impedance \\ increases with \\ teeth in gears}
\\
\addlinespace
\splitcell{Angular \\ Displacement} &
\theta_{\mathrm{new}} = \theta_{\mathrm{old}} &
\left[
\frac{\stackanchor{Number of Teeth of Gear}{in the \alert{Source} Shaft}}
{\stackanchor{Number of Teeth of Gear}{in the \alert{Destination} Shaft}}
\right] &
\splitcell{Angular \\ displacement \\ decreases with \\ teeth in gears}
\\
\CodeAfter
\SubMatrix.{2-1}{2-1}\}[xshift=-2mm]
\SubMatrix.{3-1}{3-1}\}[xshift=-2mm]
\SubMatrix.{4-1}{4-1}\}[xshift=-2mm]
\end{NiceTabular*}
\end{frame}
\end{document}