
コードを持っていますが、うまく機能します。
しかし、細かい質問として、私は自分自身に尋ねました:
最後の注釈列から右括弧までの距離を非常に小さくしたいのです。
ここで、 でnicematrix.sty
使用するのは の意味ですか? \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}
では{array}
、\hspace{2\arraycolsep}
連続する 2 つの列の間に が挿入されます。配列のプリアンブルで特殊な構造を使用することで@{...}
、これらの要素を、たとえば調整された命令など、任意のものに置き換えることができます\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}