特別な注釈を持つ行列に「nicematrix」を使用する

特別な注釈を持つ行列に「nicematrix」を使用する

を使用して次の画像を生成しましたnicematrix
すべて正常に動作しているため、現時点では緊急の問題はありません。

注記:結果や外観はまさに希望どおりです。以下では、nicematrix パッケージを最適に使用するためのコードの微妙な点についてのみ説明します。

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

しかし、個人的な興味から言えば、私は次の 2 つのことに興味がありました。

  1. "A1 A2 ... A4"全体に対して垂直方向に中央に配置する必要があります。
    ここでの使用は 適切でしょうか? それとも の意味で使用したほうがよいでしょうか?
    \Block{2-1}{A1} & \Block{2-1}{A2} & \Block{2-1}{\cdots} & \Block{2-1}{A4} ... \\

    nicematrix.sty

  2. 上と下に、"A1 A2 ... A4"マトリックスの端にそれぞれ垂直線を追加しました。
    のために下の行視覚的な調整が必要でした:
    \draw[shorten <=1em+2pt] (2-\col) -- (last-|\col.5);
    つまり、内容が変わると、再度調整が必要になる可能性が高いということです。
    これをより安定的/柔軟にすることは可能でしょうか?

コード:

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix} 
\usepackage{tikz} 
\begin{document}
$M=\begin{NiceArray}{(c c c c)  c  (c c c c)}
   &   &   &   &   \Block{*-1}{\cdot}  & B1 &    &            &   \\
\Block{2-1}{A1} & \Block{2-1}{A2} & \Block{2-1}{\cdots} & \Block{2-1}{A4} 
        &                                        &    & B2  &   &   \\
   &   &    &    &                             &     &    &  \ddots &   \\
   &   &   &   &                              &     &    &            & B4
\CodeAfter
\begin{tikzpicture}[]
% Verticals  =====================
\foreach \col in {1,2,4}{%% 
\draw[shorten <=0pt] (2-\col) -- (1-|\col.5) ; 
\draw[shorten <=1em+2pt] (2-\col) -- (last-|\col.5) ; 
}%%
\end{tikzpicture}
% Underbracing  =================
\UnderBrace[yshift=2pt]{4-6}{4-9}{=X}
\end{NiceArray}$
\end{document}

答え1

baseline=<row number>ベースラインを希望の場所にするには、 のオプションを使用できますNiceArray。ただし、 はA1ブロック内ではなく、独自の行にある必要があります。 1 つの方法として、配列を 5 行 10 列にすることができます。 次に、「2 番目の」配列で に 2 x 2 を使用しBlockます\ddots

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

その他の変更点:

  • \,列の右側と左側に細いスペース ( ) を配置して\cdot、2 つの別々の配列を使用した場合と同じ間隔になるようにします。
  • 垂直線を短くするために、新しいスタイル (myline以下のコード) を作成します。、などは独自のセル内にあるためA1A2間隔は均等になります。

コードは次のとおりです:

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix} 
\usepackage{tikz} 
\tikzset{myline/.style={shorten <=3pt}}
\begin{document}
$M=\begin{NiceArray}{(cccc)!\,c!\,(ccccc)}[baseline=3]
 & & & & \Block{*-1}{\cdot} & B1\\
 & & & & & & B2 \\
A1 & A2 & \cdots & A4 & & & & \Block{2-2}{\ddots} \\
 \\
 & & & & & & & & & B4
\CodeAfter
\begin{tikzpicture}[]
% Verticals  =====================
\foreach \col in {1,2,4}{%%  
  \draw[myline] (3-\col) -- (1-|\col.5) ; 
  \draw[myline] (3-\col) -- (last-|\col.5) ; 
}%%
\end{tikzpicture}
% Underbracing  =================
\UnderBrace[yshift=2pt]{5-6}{5-10}{=X}
\end{NiceArray}$
\end{document}

答え2

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

線を下に置いておきたい場合は、ライブラリから"A1 A2 ... A4"使用する必要があります。\tikzmarknodetikzmark

\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage{amsmath}
\usepackage{nicematrix} 
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{tikzmark}

\begin{document}
    
    \begin{equation*}
        \setlength{\arraycolsep}{1em}
        \smash{\rlap{\rule{11cm}{0.1pt}}}
        M
        =
        \begin{NiceArray}{(c c c c)  c  (c c c c)}
            \CodeBefore [create-cell-nodes]
            \Body
            &   &   &   &   \Block{*-1}{\cdot}  & B1 &    &            &   \\
            \Block{2-1}{\tikzmarknode{A1}{A1}} & \Block{2-1}{\tikzmarknode{A2}{A2}} & \Block{2-1}{\cdots} & \Block{2-1}{\tikzmarknode{A4}{A4}} 
            &                                        &    & B2  &   &   \\
            &   &    &    &                             &     &    &  \ddots &   \\
            &   &   &   &                              &     &    &            & B4
            \CodeAfter
            \begin{tikzpicture}[]
                
                % Verticals  =====================
                \draw[shorten <=1pt] (A1.north) -- (1-|1.5);
                \draw[shorten <=1pt] (A2.north) -- (1-|2.5); 
                \draw[shorten <=1pt] (A4.north) -- (1-|4.5);
                
                \draw[shorten >=1pt] (last-|1.5) -- (A1.south); 
                \draw[shorten >=1pt] (last-|2.5) -- (A2.south);
                \draw[shorten >=1pt] (last-|4.5) -- (A4.south);
                    
            \end{tikzpicture}
            % Underbracing  =================
            \UnderBrace[yshift=2pt]{4-6}{4-9}{=X}
        \end{NiceArray}
    \end{equation*}

\end{document}

関連情報