NiceMatrix:控制列空間

NiceMatrix:控制列空間

我有一個代碼並且效果很好。

但作為一個細節問題,我問自己:
我想要從最後一個註解列到右括號的距離非常小。

這裡nicematrix.sty用的是 in的意思嗎? \hspace{-0.5ex}
\newcolumntype{L}{>{\hspace{-0.5ex}$\ttfamily\footnotesize}l<{$}}

或是否nicematrix.sty知道該列間距的對應鍵?

在此輸入影像描述

\documentclass{article}
\def\NoOfVariables{3}%  Input number of variables here! %%%

\usepackage{amsmath}
\usepackage{nicematrix} 
\newcolumntype{L}{>{\hspace{-0.5ex}$\ttfamily\footnotesize}l<{$}}
\NewDocumentEnvironment{LGS}{}
{%
    \let \{ \lgroup 
    \let \} \rgroup
\begin{NiceArray}{\{ *{\NoOfVariables}{r} |  r  \} L}}%
{\end{NiceArray}}

\usepackage{fontawesome}

\newcommand\error{\faWarning}
\newcommand\mal{\ensuremath{\cdot}{}}
\newcommand\step{\hspace{1em}\ensuremath{\rightarrow}\hspace{1em}}

\begin{document}
\noindent$\begin{LGS}
1 &  2 &  -1 &  1 &  {}  \\
0 &  1 &   1 &  2 &  {}  \\
2 &  1 &   1 &  1 &  {-2\mal I}  \\
3 &  2 &   1 &  1 &  {-3\mal I}  \\
\end{LGS}
\step
\begin{LGS}
1 &  2 &  -1 &  1  &  {}  \\
0 &  1 &   1 &  2  &  {}  \\
0 & -3 &   3 & -1  &  {}  \\
0 & -4 &   4 & -2  &  {:2}  \\
\end{LGS}
\step \dots \step
\begin{LGS}
1 &  0 &  -3  &  -3  &  {}  \\
0 &  1 &   1  &   2  &  {}  \\
0 &  0 &   6  &   5  &  {}  \\
0 &  0 &   0  &   -1  &  {\error}  \\
\end{LGS}$
\end{document}

答案1

我認為你的解決方案是一個很好的解決方案。然而,由於 的環境nicematrix是基於標準環境構建的{array}(在經典包 中定義的版本中array,由 加載nicematrix),因此我建議本著 的精神解決方案{array}

在 an 中{array},an\hspace{2\arraycolsep}插入到兩個連續的列之間。透過使用@{...}陣列前導碼中的特殊結構,您可以用任何您想要的內容取代這些元素,例如\hspace{...}調整的指令。

這就是我在下面的程式碼中所做的。

\documentclass{article}
\usepackage{nicematrix} 
\newcolumntype{L}{>{$\ttfamily\footnotesize}l<{$}}
\NewDocumentEnvironment{LGS}{}
{%
    \let \{ \lgroup 
    \let \} \rgroup
\begin{NiceArray}{\{ r r r  |  r \} @{\hspace{1.8ex}} L}}% Input number of columns! %%%
{\end{NiceArray}}

\usepackage{fontawesome}
\newcommand\error{\faWarning}
\newcommand\mal{\ensuremath{\cdot}{}}
\newcommand\step{\hspace{1em}\ensuremath{\rightarrow}\hspace{1em}}

\begin{document}
\noindent$\begin{LGS}
1 &  2 &  -1 &  1 &  {}  \\
0 &  1 &   1 &  2 &  {}  \\
2 &  1 &   1 &  1 &  {-2\mal I}  \\
3 &  2 &   1 &  1 &  {-3\mal I}  \\
\end{LGS}
\step
\begin{LGS}
1 &  2 &  -1 &  1  &  {}  \\
0 &  1 &   1 &  2  &  {}  \\
0 & -3 &   3 & -1  &  {}  \\
0 & -4 &   4 & -2  &  {:2}  \\
\end{LGS}
\step \dots \step
\begin{LGS}
1 &  0 &  -3  &  -3  &  {}  \\
0 &  1 &   1  &   2  &  {}  \\
0 &  0 &   6  &   5  &  {}  \\
0 &  0 &   0  &   -1  &  {\error}  \\
\end{LGS}$
\end{document}

上述程式碼的輸出

相關內容