Math & Science ⇒ Big matrix equation and matrix rows vertical alignment
Big matrix equation and matrix rows vertical alignment
Is it possible to align rows of 2 matrices, please see attached fig for example. Rows are not aligned, but I want them to be, so that the equation is more intuitive.
Thanks!
Best,
Marko.
- Attachments
-
- meq.png (29.79 KiB) Viewed 9521 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Big matrix equation and matrix rows vertical alignment
- Attachments
-
- matrices.png (42.53 KiB) Viewed 9514 times
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Big matrix equation and matrix rows vertical alignment
It is much easier to help having some code. Nobody wants to type in the numbers to make a test document.
Big matrix equation and matrix rows vertical alignment
Code: Select all
\documentclass[conference]{article}
\usepackage[cmex10]{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\newcommand*{\mathminus}{%
\leavevmode
\hphantom{0}%
\llap{%
\settowidth{\dimen0 }{$0$}%
\resizebox{1.1\dimen0 }{\height}{$-$}%
}%
}
\begin{document}
$$
\begin{bmatrix}
\mathminus m_u^{(1)} & 0 \\
\mathminus M_{u,\varepsilon}^{(1)} & 0 \\
\mathminus M_u^{(1)} & 0 \\
m_u^{(1)} & 0 \\
\mathminus m_u^{(1)} & 0 \\
M_u^{(1)} & 0 \\
0 & \mathminus m_u^{(2)} \\
0 & \mathminus M_{u,\varepsilon}^{(2)} \\
0 & \mathminus M_u^{(2)} \\
0 & m_u^{(2)} \\
0 & \mathminus m_u^{(2)} \\
0 & M_u^{(2)} \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix} \delta_k +
\begin{bmatrix}
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix} z_k \leq
\begin{bmatrix}
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
\mathminus 1 & \mathminus 1 \\
1 & 1
\end{bmatrix} u_k +
\begin{bmatrix}
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0
\end{bmatrix} x_k +
\begin{bmatrix}
\mathminus m_u^{(1)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(1)} \\
M_u^{(1)} \\
\mathminus m_u^{(2)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(2)} \\
M_u^{(2)} \\
m_x^{(1)} \\
M_x^{(1)} \\
m_x^{(2)} \\
M_x^{(2)} \\
\mathminus m_{d,k} \\
M_{d,k}
\end{bmatrix}
$$
\end{document}
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Big matrix equation and matrix rows vertical alignment
not to use
$$ <math> $$
) because those massiveentries looked to cramped.
Code: Select all
\documentclass{article}
\usepackage[cmex10]{mathtools}
\usepackage{graphicx}
\newcommand*{\mathminus}{%
\leavevmode
\hphantom{0}%
\llap{%
\settowidth{\dimen0 }{$0$}%
\resizebox{1.1\dimen0 }{\height}{$-$}%
}%
}
\begin{document}
%$$
\[
\renewcommand{\arraystretch}{1.35}
\begin{bmatrix*}
\mathminus m_u^{(1)} & 0 \\
\mathminus M_{u,\varepsilon}^{(1)} & 0 \\
\mathminus M_u^{(1)} & 0 \\
m_u^{(1)} & 0 \\
\mathminus m_u^{(1)} & 0 \\
M_u^{(1)} & 0 \\
0 & \mathminus m_u^{(2)} \\
0 & \mathminus M_{u,\varepsilon}^{(2)} \\
0 & \mathminus M_u^{(2)} \\
0 & m_u^{(2)} \\
0 & \mathminus m_u^{(2)} \\
0 & M_u^{(2)} \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix*} \delta_k +
\begin{bmatrix*}[r]
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix*} z_k \leq
\begin{bmatrix*}[r]
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
\mathminus 1 & \mathminus 1 \\
1 & 1
\end{bmatrix*} u_k +
\begin{bmatrix*}[r]
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0
\end{bmatrix*} x_k +
\begin{bmatrix*}
\mathminus m_u^{(1)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(1)} \\
M_u^{(1)} \\
\mathminus m_u^{(2)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(2)} \\
M_u^{(2)} \\
m_x^{(1)} \\
M_x^{(1)} \\
m_x^{(2)} \\
M_x^{(2)} \\
\mathminus m_{d,k} \\
M_{d,k}
\end{bmatrix*}
%$$
\]
\end{document}
Big matrix equation and matrix rows vertical alignment
Why \[ and \] are used, what do they do? And why bmatrix* environment, because of the alignment?
Another issuse: now that you've aligned contents to the right, the right bracket is too close to contents. I can add hphantom to all entries, but is there any way to do this automatically? (only for right bracket)
Best,
Marko.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Big matrix equation and matrix rows vertical alignment
$$ math $$
is the old TeX way. LaTeX uses \[ math \]
to do the task. The starred variant for the different matrices is provided by package mathtools. If you have a lot of maths, you should check out the documentation. There are some useful things in there. Check out the following, it looks as the content is too close, but actually it just appears like that, because youre other content is so spacy.
Code: Select all
\documentclass{article}
\usepackage[cmex10]{mathtools}
\usepackage{graphicx}
\newcommand*{\mathminus}{%
\leavevmode
\hphantom{0}%
\llap{%
\settowidth{\dimen0 }{$0$}%
\resizebox{1.1\dimen0 }{\height}{$-$}%
}%
}
\begin{document}
%$$
\[
\renewcommand{\arraystretch}{1.35}
\begin{bmatrix*}
\mathminus m_u^{(1)} & 0 \\
\mathminus M_{u,\varepsilon}^{(1)} & 0 \\
\mathminus M_u^{(1)} & 0 \\
m_u^{(1)} & 0 \\
\mathminus m_u^{(1)} & 0 \\
M_u^{(1)} & 0 \\
0 & \mathminus m_u^{(2)} \\
0 & \mathminus M_{u,\varepsilon}^{(2)} \\
0 & \mathminus M_u^{(2)} \\
0 & m_u^{(2)} \\
0 & \mathminus m_u^{(2)} \\
0 & M_u^{(2)} \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix*} \delta_k +
\begin{bmatrix*}[r]
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0
\end{bmatrix*} z_k \leq
\begin{bmatrix*}[r]
1 & 0 \\
\mathminus 1 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
\mathminus 1 & \mathminus 1 \\
1 & 1
\end{bmatrix*} u_k +
\begin{bmatrix*}[r]
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
0 & 0 \\
1 & 0 \\
\mathminus 1 & 0 \\
0 & 1 \\
0 & \mathminus 1 \\
0 & 0 \\
0 & 0
\end{bmatrix*} x_k +
\begin{bmatrix*}
\mathminus m_u^{(1)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(1)} \\
M_u^{(1)} \\
\mathminus m_u^{(2)} \\
\mathminus \varepsilon \\
0 \\
0 \\
\mathminus m_u^{(2)} \\
M_u^{(2)} \\
m_x^{(1)} \\
M_x^{(1)} \\
m_x^{(2)} \\
M_x^{(2)} \\
\mathminus m_{d,k} \\
M_{d,k}
\end{bmatrix*}
+
\begin{bmatrix*}
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
0 \\
\end{bmatrix*}
1
%$$
\]
\end{document}