Seite 1 von 1

Zeilen und Spaltenbezeichnung bei Matrizen

Verfasst: Di 25. Mär 2025, 12:36
von Feedback1000
Hallo.

Ich habe versucht, die Matrix aus dem angehängten Bild nachzubauen, bin aber mit dem Ergebnis nicht zufrieden:
  1. Die Zeilen der Matrix scheinen ein wenig „gequetscht“. Kann man da einen manuellen Zeilenabstand einstellen?
  2. die obere graue Zeile (x1 x2 ... xu) passen nicht ganz zu den Spalten der Matrix.
  3. \underset ist zwar ganz funny, ist aber nicht so, wie im Bild: "n x u" müsste unter "A" stehen.

Es wäre toll, wenn mir jemand dazu ein paar Hinweise geben könnte. Danke

Hier mein aktueller Stand:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{array}

\begin{document}
	
	\[
	A := \begin{bmatrix}
		\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
		\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
		\vdots & \vdots & \ddots & \vdots \\
		\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
	\end{bmatrix}
		\]
	
	\[
	A := 
	\underset{\textcolor{gray}{(n \times u)}}{\underbrace{\begin{bmatrix}
		\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
		\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
		\vdots & \vdots & \ddots & \vdots \\
		\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
	\end{bmatrix}}}
	\]
	
	\[
	A := 
	\underset{\textcolor{gray}{(n \times u)}}{
		\underbrace{
			\begin{array}{c@{}c}
				& \begin{array}{cccc}
					\textcolor{gray}{x_1} & \textcolor{gray}{x_2} & \cdots & \textcolor{gray}{x_u}
				\end{array} \\ 
				\begin{array}{c}
					\textcolor{gray}{F_1} \\ 
					\textcolor{gray}{F_2} \\ 
					\vdots \\ 
					\textcolor{gray}{F_n}
				\end{array}
				& \left[
				\begin{array}{cccc}
					\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
					\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
					\vdots & \vdots & \ddots & \vdots \\
					\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
				\end{array}
				\right]
			\end{array}
		}
	}
	\]
	
\end{document}

Re: Zeilen und Spaltenbezeichnung bei Matritzen

Verfasst: Di 25. Mär 2025, 13:31
von Stefan Kottwitz
Hallo,
  1. kannst Du durch Vergrößern von \arraystretch machen, und danach wieder auf 1 setzen
  2. müsste man strengenommen in eine gemeinsame Matrix packen, doch man kann es auch manuell bisschen durch Einfügen von Leerraum justieren,
  3. mach halt das \underset zum A und nicht zur Matrix, wo auch noch ein \underbrace dabei ist, anscheinend hast Du den Code irgendwoher kopiert und möchtest es anders haben.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{array}

\begin{document}

\renewcommand*{\arraystretch}{2}

	\[
	\underset{\textcolor{gray}{(n \times u)}}{A} := \begin{bmatrix}
		\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
		\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
		\vdots & \vdots & \ddots & \vdots \\
		\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
	\end{bmatrix}
		\]
	
	\[
	\underset{\textcolor{gray}{(n \times u)}}{A} :=
	  \begin{bmatrix}
		\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
		\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
		\vdots & \vdots & \ddots & \vdots \\
		\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
	\end{bmatrix}
	\]
	
	\[
	\underset{\textcolor{gray}{(n \times u)}}{A} :=
			\begin{array}{c@{}c}
				& \begin{array}{cccc}
				\textcolor{gray}{\ \ \ x_1\ } & \textcolor{gray}{\ x_2\ } & \cdots\ \  & \textcolor{gray}{\!\!x_u\ \ \ }
							\end{array} \\ 
				\begin{array}{c}
					\textcolor{gray}{F_1} \\ 
					\textcolor{gray}{F_2} \\ 
					\vdots \\ 
					\textcolor{gray}{F_n}
				\end{array}
				& \left[
				\begin{array}{cccc}
					\frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} & \cdots & \frac{\partial f_1}{\partial x_u} \\
					\frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2} & \cdots & \frac{\partial f_2}{\partial x_u} \\
					\vdots & \vdots & \ddots & \vdots \\
					\frac{\partial f_n}{\partial x_1} & \frac{\partial f_n}{\partial x_2} & \cdots & \frac{\partial f_n}{\partial x_u}
				\end{array}
				\right]
			\end{array}
	\]
\end{document}
Stefan

Re: Zeilen und Spaltenbezeichnung bei Matrizen

Verfasst: Do 27. Mär 2025, 10:54
von Feedback1000
Vielen Dank. Genau das, was ich gesucht hatte.

Re: Zeilen und Spaltenbezeichnung bei Matrizen

Verfasst: Do 27. Mär 2025, 11:01
von Feedback1000
Nun würde ich gern noch die Einträge der Diagonale einfärben. Müsste ich jetzt jeden Eintrag manuell einfärben, oder gibt es da auch einen coolen Kniff?

Re: Zeilen und Spaltenbezeichnung bei Matrizen

Verfasst: Fr 4. Apr 2025, 11:03
von Feedback1000
Mir ist aufgefallen, dass "A :=" nicht mittig zum "Matrix-Konstrukt" ausgerichtet ist. Es müsste noch ein wenig tiefer stehen. Siehst du da noch eine Möglichkeit?

Re: Zeilen und Spaltenbezeichnung bei Matrizen

Verfasst: Sa 5. Apr 2025, 12:32
von Stefan Kottwitz
Du kannst \raisebox verwenden, beispielsweise so:
\raisebox{-4pt}{$\underset{\textcolor{gray}{(n \times u)}}{A} :=$}
Stefan