我需要使用NiceMatrixBlock
里面一个等式,但这样做会引起间距问题。有办法解决这个问题吗?
梅威瑟:
\documentclass{article}
\usepackage{mathtools,nicematrix}
\begin{document}
A test equation:
\begin{align}
e^{i\pi}+1=0
\end{align}
With NiceMatrixBlock outside align:
\begin{NiceMatrixBlock}[auto-columns-width]%
\begin{align}
\begin{dcases}
\begin{NiceArrayWithDelims}{[}{]}{cc}
a &b\\
ccccc &d\\
\end{NiceArrayWithDelims}
\\
\begin{NiceArrayWithDelims}{[}{]}{ccc}
a &b &c\\
d &e &f\\
\end{NiceArrayWithDelims}
\end{dcases}
\end{align}
\end{NiceMatrixBlock}
With NiceMatrixBlock inside align:
\begin{align}
\begin{NiceMatrixBlock}[auto-columns-width]%
\begin{dcases}
\begin{NiceArrayWithDelims}{[}{]}{cc}
a &b\\
ccccc &d\\
\end{NiceArrayWithDelims}
\\
\begin{NiceArrayWithDelims}{[}{]}{ccc}
a &b &c\\
d &e &f\\
\end{NiceArrayWithDelims}
\end{dcases}
\end{NiceMatrixBlock}
\end{align}
\end{document}
答案1
这是 中的一个错误nicematrix
。我在 CTAN 上发布了一个新版本nicematrix
(v. 2.23, 2023-09-02),解决了该问题。
答案2
它会因测量过程而感到困惑,nicematrix 维护者通常会忽略它,并且可能会提供更好的答案,但一个简单的解决方法是先在一个盒子里执行 nicematrix 块。
\documentclass{article}
\usepackage{mathtools,nicematrix}
\newbox\hmmm
\begin{document}
A test equation:
\begin{align}
e^{i\pi}+1=0
\end{align}
With NiceMatrixBlock outside align:
\begin{NiceMatrixBlock}[auto-columns-width]%
\begin{align}
\begin{dcases}
\begin{NiceArrayWithDelims}{[}{]}{cc}
a &b\\
ccccc &d\\
\end{NiceArrayWithDelims}
\\
\begin{NiceArrayWithDelims}{[}{]}{ccc}
a &b &c\\
d &e &f\\
\end{NiceArrayWithDelims}
\end{dcases}
\end{align}
\end{NiceMatrixBlock}
With NiceMatrixBlock inside align:
\setbox\hmmm=\hbox{$%
\begin{NiceMatrixBlock}[auto-columns-width]%
\begin{dcases}
\begin{NiceArrayWithDelims}{[}{]}{cc}
a &b\\
ccccc &d\\
\end{NiceArrayWithDelims}
\\
\begin{NiceArrayWithDelims}{[}{]}{ccc}
a &b &c\\
d &e &f\\
\end{NiceArrayWithDelims}
\end{dcases}
\end{NiceMatrixBlock}$}
\begin{align}
aaa&bbb\\
\usebox\hmmm
&ccc
\end{align}
\begin{align}
e^{i\pi}+1=0
\end{align}
\end{document}