
Ich muss eine 2x2-Matrix gleichmäßig in die 4. und 5. Zeile und die 4. und 5. Spalte einer 5x5-Matrix einfügen. Mein Code muss optimiert werden.
\begin{equation*}
a_1=
\begin{bmatrix}
1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & & {\begin{bmatrix} & b & \end{bmatrix}}\\
0 & 0 & 0 &
\end{bmatrix}
\end{equation*}
Antwort1
Oder vielleicht mit nicematrix
. Es erfordert ein zusätzliches Paket (das wiederum andere Sachen lädt, vor allem TikZ), wobei der Abstand zwischen den Spalten jedoch nicht verändert wird und Sie die volle Kontrolle über alle Aspekte des Erscheinungsbilds haben.
\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}
\begin{document}
\begin{equation*}
a_1=\begin{bNiceMatrix}[name=mymatrix]
1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & \phantom{0} & \phantom{0}\\
0 & 0 & 0 & \phantom{0} & \phantom{0}
\end{bNiceMatrix}
\begin{tikzpicture}[remember picture,overlay]
\node[fit=(mymatrix-4-4)(mymatrix-5-5),inner sep=-0.2ex,text height=1.2em] (f){$b$};
\draw[thick] ([xshift=0.5ex]f.south west)-| (f.north west) -- ++ (0.5ex,0)
([xshift=-0.5ex]f.south east)-| (f.north east) -- ++ (-0.5ex,0);
\end{tikzpicture}
\end{equation*}
\end{document}
Antwort2
Anstelle von bmatrix
habe ich für die 2x2 Matrix verwendet matrix
. Aber das ist nur eine persönliche Vorliebe und kann problemlos ausgetauscht werden.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
a_1=
\begin{bmatrix}
\begin{matrix}
1 & 0 & 0\\
0 & 0 & 0 \\
0 & 0 & 0
\end{matrix} &
\begin{matrix}
0 & 0\\
0 & 0 \\
0 & 0
\end{matrix}\\
\begin{matrix}
0 & 0 & 0\\
0 & 0 & 0
\end{matrix} &
\begin{matrix} & b & \end{matrix}\\
\end{bmatrix}
\end{equation*}
\end{document}
Ergebnis mit matrix
:
Ergebnis mit bmatrix
:
Antwort3
Eine Lösung mit blkarray
:
\documentclass{article}
\usepackage{multirow}
\usepackage{blkarray, bigstrut}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
a_1=
\left[
\begin{blockarray}{@{\,}ccccc@{\:}}
\bigstrut[t]
1 & 0 & 0 & 0 & 0 & \\
0 & 0 & 0 & 0 & 0 & \\
0 & 0 & 0 & 0 & 0 & \\
\begin{block}{@{\,}ccc[\BAmulticolumn{2}{!{}c!{}}@{\:}]}
0 & 0 & 0 & \multirow{2}{*}{b}\\
0 & 0 & 0 & \\
\end{block}
\BAnoalign{\vskip -7ex}
\end{blockarray}\right]
\end{equation*}
\end{document}