
Tengo un código y funciona bien.
Pero por cuestión de detalle me pregunté:
quiero una distancia muy pequeña desde la última columna de anotación hasta el paréntesis derecho.
¿Tiene el sentido de nicematrix.sty
usarlo \hspace{-0.5ex}
aquí,
en \newcolumntype{L}{>{\hspace{-0.5ex}$\ttfamily\footnotesize}l<{$}}
?
¿O nicematrix.sty
conoce la clave correspondiente para el espaciado de esta columna?
\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}
Respuesta1
Creo que tu solución es una buena solución. Sin embargo, dado que los entornos de nicematrix
se construyen sobre el entorno estándar {array}
(en la versión definida en el paquete clásico array
, que carga nicematrix
), sugiero una solución en el espíritu de {array}
.
En un {array}
, \hspace{2\arraycolsep}
se inserta un entre dos columnas consecutivas. Al utilizar la construcción especial @{...}
en el preámbulo de la matriz, puede reemplazar estos elementos por lo que desee, por ejemplo, una instrucción \hspace{...}
ajustada.
Eso es lo que he hecho en el siguiente código.
\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}