7

enter image description here

can somebody please help me how to get the '=' in different equations always at the center of the page so that they are always above the other? thanks!

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}

\begin{document}

some text ...

\begin{align}\label{eqn:SE}
{\rm{SE}} &= \sqrt {\frac{{\sum\nolimits_{i = 1}^n {{{\left( {{x_i} -      \bar x} \right)}^2}} }}{{n \cdot \left( {n - 1} \right)}}} \\  &=     \frac{{{\rm{SD}}}}{{\sqrt n }}
\end{align}

some text ...

\begin{align}\label{eqn:SEM}
{\rm{RSE}} = \frac{{{\rm{SEM}}}}{{\bar x}} \cdot \SI{100}{\percent} 
\end{align}

\end{document}
Hiasl
  • 261
  • 3
    although it's possible (and desirable) to align = signs in consecutive equations, no provision has, to the best of my knowledge, ever been made to center the = signs horizontally on a page. there are simply too many situations in which one side of an equation is much wider than the other, and there's a real risk of exceeding the margin on one side or the other if the = signs are centered. further, if such a requirement (even optionally) were part of the "general" multi-line equation handling code, it would slow down processing, perhaps very noticeably, for everyone. – barbara beeton Oct 14 '16 at 15:22

2 Answers2

7

Use the \intertext command of the amsmath package. As a side-note, use \mathrm instead of \rm. Moreover, it's usually better not to clutter the code with unnecessary braces, since it becomes harder to understand. Finally, \left-\right is only needed when enclosing terms of unusual height in parentheses.

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\begin{document}
some text ...
\begin{align}
  \mathrm{SE} 
   &= \sqrt{\frac{\sum\nolimits_{i = 1}^n {(x_i-\bar x)}^2 }%
                 {n \cdot (n-1)}
           }                                               \label{eqn:SE} \\
   &=  \frac{\mathrm{SD}}{\sqrt n}                         \label{eqn:SE2}\\
\intertext{some text ...}
  \mathrm{RSE}
   &= \frac{\mathrm{SEM}}{\bar x} \cdot \SI{100}{\percent} \label{eqn:SEM}
\end{align}
\end{document}

enter image description here

gernot
  • 49,614
  • thanks, but is there also a general solution? this would not be convenient in a very large paper... – Hiasl Oct 14 '16 at 13:24
  • 1
    @Hiasl I'm not aware of such a feature, but I also have never encountered the necessity. It might not exist, because it is not so convenient after all: Your equations will end up strangely off-center without apparent reason on the current page, if there is an equation with a wide left- or right-hand side somewhere else. – gernot Oct 14 '16 at 13:48
  • @gernot While I can see no good reason to keep alignment across pages, one could reasonably want to keep it on a single page. I do not think anyone would recommend having a whole page in math environment. – user114516 Oct 14 '16 at 15:04
  • @JM114516 I'm just talking from my limited experience: Usually I only wanted to keep up the alignment in a limited range, with some verbal injections supporting the argument. Maybe someone adds an answer with a more general approach, let's see. – gernot Oct 14 '16 at 15:18
  • 1
    It sounded to me like the OP wanted the equals signs not only aligned, but centered. It seems worth pointing out that this solution will achieve the alignment, but the equals signs may still be very far off-center. – Emma Oct 14 '16 at 17:26
4

If you really want the equals sign centered, you might try defining an environment like

\newenvironment{calign}
  {\align\hspace{.5\textwidth} &\hspace{.5\textwidth}\notag\\[-2em]}
  {\endalign}

Then you can replace all of your aligns with caligns to ensure that the equals sign is always in the same place. (Here it is actually the left end of the = which is centered. It doesn't make a huge difference to the layout, and you could probably fix it using the calc package if you need to.)

This is probably not a particularly robust solution and might need to be adjusted, e.g., if you have changed the vertical spacing in align environments. It will also break if the LHS of the equation doesn't fit in the allotted space, in which case it will push the tag numbers off the edge (but for this case you can still revert to the original align environment.)

You can do a similar but slightly more complicated thing if you need a starred version as well.

Emma
  • 3,453
  • 12
  • 20