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 9026 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Big matrix equation and matrix rows vertical alignment
- Attachments
-
- matrices.png (42.53 KiB) Viewed 9019 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 \\
- 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 \\
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 \\