Seite 1 von 1
Matrix align
Verfasst: Mi 20. Nov 2013, 02:09
von Lucas1234
Hallo,
ich stehe auf dem Schlauch, ich möchte die Submatrizen zweier Matrizen auszurichten.
Hat jemand eine Idee?
Vielen Dank im Voraus,
Lucas
% Das ist mein LaTeX-Dokument.
\begin{equation}
\begin{array}{cccc|ccc|ccc|cc}
\textbf{H} = [&a & b&\hdots &-1\ &0&\hdots&\ &0 &\hdots & 1 & 0 \\
&0 &0&\hdots & \ddots & & &\ & &\hdots & 1 & 0 \\
&0&0&\hdots & a_1 & b_i& -1 &\ &0 &\hdots & 1 & 0 ]\\
\\
\textbf{H} = [\ &\textbf{0} &\ &\ &\textbf{H}_{LS} &\ &\ &\textbf{0} &\ &\ & \textbf{H}_{t_{rv}} &\ ] \\
\end{array}
\label{eq:ekf_H0_tx_loc}
\end{equation}
Re: Matrix align
Verfasst: Mi 20. Nov 2013, 05:21
von skater
Lucas1234 hat geschrieben:Hat jemand eine Idee?
Well – ich hätte die Idee, dass du ein echtes Minimalbeispiel machst.
Vielen Dank im Voraus,
Nichts zu danken, gerne geschehen.
Verfasst: Mi 20. Nov 2013, 08:29
von Stefan Kottwitz
Hallo Lukas,
zum Sinn eines Minimalbeispiels siehe auch hier:
Was ist ein vollständiges Minimalbeispiel. Hier ist es zwar nicht sehr ausschlaggebend, da wenige Einstellungen erforderlich, doch Du verstehst den Sinn vmtl. aus der Sicht: jeder Leser muss zum Testen ein komplettes Dokument drumherumbasteln, nur weil der Fragesteller es nicht einmalig getan hat. Vervielfachung von Arbeit, vmtl. macht sich nicht jeder die Extra-Mühe und Du verpasst halt Antworten und Lösungen.
Du möchtest ausrichten? Wie und wo? Oben, unten, linksbündig, rechts, mittig, ... evtl. zeige in einer Skizze, was Du meinst oder erkläre es genauer.
Stefan
Verfasst: Mi 20. Nov 2013, 10:38
von Lucas1234
Stefan hat geschrieben:
jeder Leser muss zum Testen ein komplettes Dokument drumherumbasteln, nur weil der Fragesteller es nicht einmalig getan hat.
Stefan
Alles klar, ich habe es vervollständigt
Stefan hat geschrieben:
Du möchtest ausrichten? Wie und wo? Oben, unten, linksbündig, rechts, mittig, ... evtl. zeige in einer Skizze, was Du meinst oder erkläre es genauer.
Stefan
Die Submatrizen sollen übereinander stehen.
% Das ist mein LaTeX-Dokument.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{array}{cccc|ccc|ccc|cc}
\textbf{H} = [&a & b&\hdots &-1\ &0&\hdots&\ &0 &\hdots & 1 & 0 \\
&0 &0&\hdots & \ddots & & &\ & &\hdots & 1 & 0 \\
&0&0&\hdots & a_1 & b_i& -1 &\ &0 &\hdots & 1 & 0 ]\\
\\
\textbf{H} = [\ &\textbf{0} &\ &\ &\textbf{H}_{LS} &\ &\ &\textbf{0} &\ &\ & \textbf{H}_{t_{rv}} &\ ] \\
\end{array}
\label{eq:ekf_H0_tx_loc}
\end{equation}
\end{document}
Das Beispiel funktioniert grob, nur dass ich Probleme habe, die Klammer der Matrizen zu setzen.
% Das funktioniert nicht.
\documentclass{article}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{array}{cccc|ccc|ccc|cc}
\textbf{H} = \left[&a & b&\hdots &-1\ &0&\hdots&\ &0 &\hdots & 1 & 0 \\
&0 &0&\hdots & \ddots & & &\ & &\hdots & 1 & 0 \\
&0&0&\hdots & a_1 & b_i& -1 &\ &0 &\hdots & 1 & 0 \right]\\
\textbf{H} = [\ &\textbf{0} &\ &\ &\textbf{H}_{LS} &\ &\ &\textbf{0} &\ &\ & \textbf{H}_{t_{rv}} &\ ] \\
\end{array}
\label{eq:ekf_H0_tx_loc}
\end{equation}
\end{document}
Danke,
Lucas
Verfasst: Mi 20. Nov 2013, 15:54
von esdd
Hier ist mal ein Vorschlag mit tikz:
\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,fit,calc}
\tikzset{
klammern/.style={left delimiter=[,right delimiter={]}},
mymathmatrix/.style={matrix of math nodes,ampersand replacement=\&,
nodes={text width=#1,align=center},nodes in empty cells,klammern,font=\strut},
mysubmatrix/.style={font=\strut,anchor=north},
klammerneinfuegen/.style={fit=#1,klammern,align=none,inner sep=0pt}
}
\begin{document}
\begin{equation}
\begin{tikzpicture}[baseline=(m1.base),font=\strut]
% obere Matrix mit Klammern
\matrix(m1)[mymathmatrix=1.3em]{
a \& b\&\hdots \&[2*\tabcolsep]-1\&0\&\hdots
\&[2*\tabcolsep]\&0 \&\hdots \&[2*\tabcolsep] 1 \& 0 \\
0 \&0\&\hdots \& \smash{\ddots} \& \& \& \& \&\hdots \& 1 \& 0 \\
0\&0\&\hdots \& a_1 \& b_i\& -1 \& \&0 \&\hdots \& 1 \& 0\\
};
% untere Matrix ohne Klammern
\foreach \l/\r/\inhalt in
{1/3/\mathbf{0}, % 0 mittig unter 1. bis 3. Spalte der oberen Matrix
4/6/\mathbf{H}_{LS}, % H_LS mittig unter 4. bis 6. Spalte der oberen Matrix
7/9/\mathbf{0},
10/11/\mathbf{H}_{t_{rv}}}{
\node(ms\l)[mysubmatrix] at
([yshift=-\baselineskip]$(m1-1-\l.west|-m1.south)!0.5!(m1-1-\r.east|-m1.south)$)
{$\inhalt$};}
% Klammern für untere Matirx
\node(m2)[klammerneinfuegen=(m1.west|-ms1.north) (m1.east|-ms1.south)]{};
% senkrechte Striche in beiden Matrizen
\foreach \i in
{3,6,9}{
\draw([xshift=\tabcolsep]m1-1-\i.north east|-m1.north)
--([xshift=\tabcolsep]m1-1-\i.north east|-m1.south)coordinate(r\i);
\draw(r\i|-m2.north)--(r\i|-m2.south);}
% linke Seiten der Gleichungen
\foreach \i in {1,2}{\node[anchor=east]at(m\i.west){$\mathbf{H}=~$};}
\end{tikzpicture}
\label{eq:ekf_H0_tx_loc}
\end{equation}
\end{document}
Vielleicht geht das aber doch noch irgendwie einfacher.
Gruß
Elke
Verfasst: Mi 20. Nov 2013, 20:49
von Lucas1234
Hallo Elke,
vielen Dank, es sieht genau so wie ich es mir vorgestellt habe.
Lucas
