nicematrix: 最後の列に ttfamily を追加します

nicematrix: 最後の列に ttfamily を追加します

nicematrix最後の注釈列を自分用に\footnotsize入力するにはどうすればいいでしょうか?\ttfamily

注: ここでは通常、記号+, -, ·とローマ数字 ( I, II, III,...) を使用します。
したがって、ここで数式モードを維持する必要はありません。

したがって、考えられる結果は次のようになります。

ここに画像の説明を入力してください

私のMWE:

ここに画像の説明を入力してください

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix} 
\usepackage{tikz} 
\begin{document}

$\begin{bNiceArray}{c c c   |   c}[
last-col,
%code-for-last-col = ???,
]
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & II + 2\mathord{\cdot} I - III  \\
0 & 1 & 1 & 3 &
\end{bNiceArray}$
\end{document}

ところで、ここでは括弧 '[ ]' の代わりに括弧を\lgroup使いたいのですが、マニュアルでそのことは知っていますが、初めての試みなので、他のものとはうまく合いません。ここでグループ括弧を使用する簡単な方法はありますか?\rgroupNiceArrayWithDelims

答え1

アップデート

の最新バージョン(v. 6.16) では、 などの環境のプリアンブルに、区切り文字と(および を介して)nicematrixを直接配置できるようになりました。\lgroup\rgroup\left\lbroup\right\rgroup{NiceArray}

新しいバージョンでは、次のように記述できます。

\documentclass{article}
\usepackage{nicematrix} 
\usepackage{amsmath}

\begin{document}

\newcolumntype{L}{>{$\ttfamily\footnotesize}l<{$}}

$\begin{NiceArray}{\left\lgroup ccc|c\right\rgroup L}
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & II + 2I - III  \\
0 & 1 & 1 & 3 & \\
0 & 1 & 1 & 5 &
\end{NiceArray}$

\end{document}

上記コードの出力


nicematrix申し訳ありませんが、現在のバージョン(6.15)ではそれができません。

必要に応じて、回避策があります。キーは使用せずlast-col、配列のプリアンブルに列を明示的に追加し、プリアンブル内に括弧を配置します。

\documentclass{article}
\usepackage{nicematrix} 
\usepackage{amsmath}

\begin{document}

\newcolumntype{L}{>{$\ttfamily\footnotesize}l<{$}}

$\begin{NiceArray}{(ccc|c)L}
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & II + 2I - III  \\
0 & 1 & 1 & 3 & \\
0 & 1 & 1 & 5 &
\end{NiceArray}$

\end{document}

最初のコードの出力

プリアンブルに区切り文字とを入れることはできませんが\lgroup、ここでは、以前に再定義されたと\rgroupを入れるというトリックがあります...\{\}

\documentclass{article}
\usepackage{nicematrix} 
\usepackage{amsmath}

\begin{document}

\newcolumntype{L}{>{$\ttfamily\footnotesize}l<{$}}

\NewDocumentEnvironment{MyNiceArray}{}
  {%
    \let \{ \lgroup 
    \let \} \rgroup
    \begin{NiceArray}%
  }
  {\end{NiceArray}}

$\begin{MyNiceArray}{\{ccc|c\}L}
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & II + 2I - III  \\
0 & 1 & 1 & 3 & \\
0 & 1 & 1 & 5 &
\end{MyNiceArray}$

\end{document}

上記コードの出力

答え2

おそらく次のようなものが解決策になるでしょうが、ノードの内容はデフォルトで数式モードになっているため\ttfamily使用できないため、注釈を\textttマクロに配置する必要があります。

\documentclass{article}
\usepackage{nicematrix} 
\usepackage{tikz} 

\begin{document}

$\begin{NiceArrayWithDelims}{\lgroup}{\rgroup}{ c c c | c }[
    last-col,
    code-for-last-col={\footnotesize}
]
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & \texttt{II + 2\cdot I - III} \\
0 & 1 & 1 & 3 &
\end{NiceArrayWithDelims}$

\end{document}

ここに画像の説明を入力してください

私の知る限り、 ではnicematrix最後の列の内容を何らかのマクロで囲む方法は提供されておらず、 を使用してマクロを先頭に追加することしかできませんが、ここではあまり役に立ちません。また、環境が完全に数式モードである必要があるcode-for-last-colため、逆に、関連する列のみを数式モードでタイプセットすることもできません。NiceArrayWithDelims


\SubMatrix区切り文字をもう少し大きくしたい場合は、オプションを提供するネストされたを使用できますextra-height(この解決策はパッケージの作者によって提案されています)。たとえば、ここ):

\documentclass{article}
\usepackage{nicematrix} 
\usepackage{tikz} 

\NewDocumentEnvironment{ MybNiceArray } { } { 
    \NiceMatrixOptions{exterior-arraycolsep}
    \begin{NiceArray} 
} {
    \CodeAfter
        \SubMatrix\lgroup{1-1}{last-last}\rgroup[extra-height=1ex]
    \end{NiceArray}
}

\begin{document}

$\begin{MybNiceArray}{ c c c | c }[
    last-col,
    code-for-last-col={\footnotesize}
]
1 & -2 & 3 & 5 & \\
0 & 3 & 2 & 2 & \texttt{II + 2\cdot I - III} \\
0 & 1 & 1 & 3 &
\end{MybNiceArray}$

\end{document}

ここに画像の説明を入力してください

関連情報