1

I have a problem with the second equation not centering when split. Here is my code:

\begin{equation} 
    \begin{split}
        \textnormal{A}= 
        \begin{pmatrix}
            \cos(\pi/4) & -\sin(\pi/4) & 0\\
            \sin(\pi/4) & \cos(\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}
        ;
        \textnormal{B}=
        \begin{pmatrix}
            \cos(-\pi/4) & -\sin(-\pi/4) & 0\\
            \sin(-\pi/4) & \cos(-\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}\\
        \\
        \textnormal {AB}=\textnormal {BA}
        =
        \begin{pmatrix}
            1 & 0 & 0\\
            0 & 1 & 0\\
            0 & 0 & 1
        \end{pmatrix}
    \end{split}
    \label{eq:inverse2}
\end{equation}  

Thank you in advance

  • 1
    unrelated to the alignment, but you should (probably) use \mathrm{A} not \textnormal{A} – David Carlisle May 10 '17 at 20:18
2

I would use the gathered environment provided by amsmath

 \documentclass{article}
\usepackage{amsmath,mathtools}
\newcommand{\matr}[1]{\mathrm{#1}}
\begin{document}
\begin{equation}\label{eq:inverse2}
    \begin{gathered}
        \matr{A}= 
        \begin{pmatrix}
            \cos(\pi/4) & -\sin(\pi/4) & 0\\
            \sin(\pi/4) & \hphantom{-}\cos(\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}\\[2ex]
        \matr{B}=
        \begin{pmatrix}
            \cos(-\pi/4) & -\sin(-\pi/4) & 0\\
            \sin(-\pi/4) & \hphantom{-}\cos(-\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}\\[2ex]
      \matr {A}\matr{B}=\matr {B}\matr{A}
        =
        \begin{pmatrix}
            1 & 0 & 0\\
            0 & 1 & 0\\
            0 & 0 & 1
        \end{pmatrix}
    \end{gathered}
    \end{equation}


\end{document}

In my opinion split is best suited when one has to write a single long equation spanning more lines. Yours is clearly not the case.

Please consider also the gather environment (without equation) if you want to have one equation number per line.

The amsmath package documentation defines these and other useful environments, I invite you to browse through it to choose which one is best for your application.

Also, important:

  1. To display roman in math environment, use \mathrm command;

  2. Also, if you find yourself dealing with matrices, it would be better to define a command that represents their name in roman font, ie a shortcut to \mathrm to typeset them (quickly interchangeable if you want to and more readable). I defined the \matr command in this spirit (thanks to @egreg)

EDIT

Also, thanks to @egreg, I have noticed that the equation is best suited over three lines, since the two matrices are quite big; I reorganized the whole thing in a (I think) better fashion

enter image description here

| improve this answer | |
  • @Mico thanks, I corrected it, I pasted the wrong code (and the right one took me a bit of time to edit) – Moriambar May 10 '17 at 20:46
  • this is nitpicking, but i think it would look nicer if the minus sign in the second column of the matrices didn't cause "sin" and "cos" to be offset from one another. \hphantom{-} would shift the "cos" to the right just enough to line them up. – barbara beeton May 26 '17 at 19:44
  • @barbarabeeton you are right, thanks; I just corrected it – Moriambar May 26 '17 at 19:50
2

You should use gathered, not split, which is done to align parts of equations. I also suggest you use the \mfrac command from nccmath (medium-sized fraction, ~ 80 % of \displaystyle) in the place of a/b which uses more horizontal spacing, and add some spacing between the two matrices in the first line:

\documentclass{article}
\usepackage{geometry} 

\usepackage{mathtools, nccmath}

\begin{document}

\begin{equation}
    \begin{gathered}
        \mathrm{A}=
        \begin{pmatrix}
            \cos(\pi/4) & -\sin(\pi/4) & 0\\
            \sin(\pi/4) & \cos(\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}
        ;\quad
        \mathrm{B}=
        \begin{pmatrix}
            \cos(-\pi/4) & -\sin(-\pi/4) & 0\\
            \sin(-\pi/4) & \cos(-\pi/4) & 0\\
            0 & 0 & 1
        \end{pmatrix}
        \\[1ex]
        \mathrm{AB}=\mathrm{BA}
        =
        \begin{pmatrix}
            1 & 0 & 0\\
            0 & 1 & 0\\
            0 & 0 & 1
        \end{pmatrix}
    \end{gathered}
    \label{eq:inverse2}
\end{equation}
\vspace{1cm}

\begin{equation}
    \begin{gathered}
\renewcommand{\arraystretch}{1.5}
        \mathrm{A}=
        \begin{pmatrix}
            \cos\bigl(\mfrac{\pi}{4}\bigr) & -\sin\bigl(\mfrac{\pi}{4}\bigr) & 0\\
            \sin\bigl(\mfrac{\pi}{4}\bigr) & \cos\bigl(\mfrac{\pi}{4}\bigr) & 0\\
            0 & 0 & 1
        \end{pmatrix}
        ;\quad
        \mathrm{B}=
        \begin{pmatrix}
            \cos\bigl(-\mfrac{\pi}{4}\bigr) & -\sin\bigl(-\mfrac{\pi}{4}\bigr) & 0\\
            \sin\bigl(-\mfrac{\pi}{4}\bigr) & \cos\bigl(-\mfrac{\pi}{4}\bigr) & 0\\
            0 & 0 & 1
        \end{pmatrix}
\renewcommand{\arraystretch}{1.25}
        \\[1ex]
        \mathrm{AB}=\mathrm{BA}
        =
        \begin{pmatrix}
            1 & 0 & 0\\
            0 & 1 & 0\\
            0 & 0 & 1
        \end{pmatrix}
    \end{gathered}
    \label{eq:inverse2}
\end{equation}

\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.