Ich habe das folgende Bild mit erstellt nicematrix
.
Alles funktioniert einwandfrei, es liegt also derzeit kein dringendes Problem vor.
Notiz:Das Ergebnis bzw. die Optik ist genau wie gewünscht. Nachfolgend gehe ich nur auf ein paar Feinheiten des Codes ein, um das nicematrix-Paket optimal nutzen zu können.
Aus persönlichem Interesse hätten mich jedoch 2 Dinge interessiert:
"A1 A2 ... A4"
sollte vertikal zum Ganzen zentriert sein.
Ist meine Verwendung von hier in Ordnung? Oder hätte ich es besser im Sinne von sagen sollen ?
\Block{2-1}{A1} & \Block{2-1}{A2} & \Block{2-1}{\cdots} & \Block{2-1}{A4} ... \\
nicematrix.sty
Darüber und darunter
"A1 A2 ... A4"
habe ich jeweils vertikale Linien zu den Enden der Matrix hinzugefügt.
Für dieuntere ZeilenIch musste eine optische Anpassung vornehmen:
\draw[
shorten <=1em+2pt
] (2-\col) -- (last-|\col.5);
Das heißt, wenn sich die Inhalte ändern, sind vermutlich wieder Anpassungen nötig.
Könnte man das eventuell stabiler/flexibler gestalten?
Code:
\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}
Antwort1
Um die Grundlinie an die gewünschte Stelle zu bringen, können Sie die Option baseline=<row number>
für verwenden NiceArray
. Dazu muss sich das jedoch A1
in einer eigenen Zeile befinden, nicht in einem Block. Eine Möglichkeit besteht darin, Ihr Array mit 5 Zeilen und 10 Spalten zu erstellen. Verwenden Sie dann im „zweiten“ Array ein 2 x 2 Block
für \ddots
.
Weitere Änderungen:
\,
Fügen Sie rechts und links von der Spalte ein kleines Leerzeichen ( ) ein\cdot
, sodass der Abstand der gleiche ist, als ob Sie zwei separate Arrays verwendet hätten.- Erstellen Sie einen neuen Stil (
myline
im Code unten), um die vertikalen Linien zu kürzen. Da sichA1
,A2
, usw. in ihren eigenen Zellen befinden, ist der Abstand gleichmäßig.
Hier ist der Code:
\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}
Antwort2
Wenn Sie möchten, dass die Zeilen darunter bleiben "A1 A2 ... A4"
, müssen Sie \tikzmarknode
aus tikzmark
der Bibliothek verwenden
\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}