2

Is there a way to align all the equal signs in all equations all over the document? I write a theses (scrbook) and like all equal signs to line up. At least in a chapter if not possible for the whole document.

The \begin{align} or \begin{eqnarray} just do that for the small group. And to use \intertext for a whole chapter is unpractikal.

Example how it is at the moment:

\begin{align}    
F_L^{\rightarrow}   & =     q ( E_{eFeld}^{\rightarrow} + v^{\rightarrow} \times B^{\rightarrow} )
    \end{align}

much text

    \begin{align}
    F_{Lx}  & =     q ( E_{eFeld} + v_{gx} * B )
    \end{align}

    little text

    \begin{align}
    T   & =     F_{L1} - F_{L2}                                         \\
        & =     q ( E_{eFeld} + v_{g1} * B - E_{eFeld} - v_{g2} * B )   \\
        & =     q*B ( v_{g1} - v_{g2} )         
    \end{align}                     

    \subsection{new subsection}

    very little text

    \begin{align}
    P_{Photon}  & =     hf * nAc                \\
                & =     \frac{E_{Photon}}{t}    
    \end{align}

    more text

    \begin{align}
    F_{0}       & =     2nhfA               \\
                & =     \frac{2 P_{Photon}}{c}  
    \end{align}

And I would like to have something like:

A  = b+C

Text

A  = longe equation

**New Headline**

B  = also nice equation

And so on. I guess you get what I want. Can you help me? Thank you

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
Göran
  • 21
  • 6
    This does not sound like a good idea; one equation with a long left-hand side will force all the others to be indented. Perhaps you would prefer to be using the fleqn option, that sets all equations with a fixed indent from the left margin, rather than centered. – Andrew Swann Jul 02 '13 at 10:17
  • I tried fleqn. It looks not good. If there are sutch unplesant left-hand equations I guess there it a way to exclude them from the alignment like it is with the numbering. – Göran Jul 02 '13 at 10:30
  • 3
    But if you insist upon it, see http://tex.stackexchange.com/questions/115534/align-separate-equations/115549#115549 where I created the algneqn environment – Steven B. Segletes Jul 02 '13 at 10:31
  • Thanks. Now I have the problem that the algneqn changes the sice of the \frac{}{}. It becomes pushed together to fit on a line. Can you help with that. (I tried to chance the definition of algneqn from equation to align and equnarry what both created errors) – Göran Jul 02 '13 at 11:11
  • 1
    unrelated to question but don't do P_{Photon} math italic is designed to make adjacent letters not look like a word. use P_{\mathrm{Photon}} or P_{\mathit{Photon}} – David Carlisle Jul 02 '13 at 11:41
  • Thanks for the P_{\mathit{}}. Looks mutch better. Has anybody a solution for the \frac{}{} Problem that it is nicely big again. – Göran Jul 07 '13 at 16:26
  • @Göran Sorry I did not get your message to me (you needed to say @Steven Segletes in order for me to be alerted). To fix a \frac displaying in \textstyle, you have two choices: 1) Add the macro \displaystyle prior to the \frac, or else, put \usepackage{amsmath} in the preamble and then use \dfrac, which is short for \displaystyle\frac. – Steven B. Segletes Jul 28 '13 at 17:33

1 Answers1

3

Starting with my answer on align separate equations, I found I needed to change a few things, specifically because the OP for this question wanted to include multiline equations. As such, I had to reinstate \arraystretch to a non-zero value (in fact, I set it to 1.2). But with that, I had to do some \vspace manipulations going into and out of the algneqn environment I created.

But in the end, all the equal signs are aligned, per the OP's request. Setting the values of \leftalgn and \rightalgn will determine where on the overall line the alignment tab will be set.

\documentclass{article}
\usepackage{amsmath}
\def\leftalgn{0.3}\def\rightalgn{0.6}
\def\algnrow{\rule{\leftalgn\textwidth}{0ex}&\rule{\rightalgn\textwidth}{0ex}}
% CONSTRAINTS:
% equation label must fit in {1 -\leftalgn -\rightalgn}\textwidth
% \leftalgn must be larger than any text to left of align character
% \rightalgn must be larger than any text to right of align character
\newenvironment{algneqn}{%
  \vspace{-1.6\baselineskip}%
  \arraycolsep=0ex\renewcommand\arraystretch{1.2}%
  \begin{equation}%
  \begin{array}{rl}%
  \algnrow\\%
}%
 {\\\algnrow%
  \end{array}\vspace{-\baselineskip}%
  \end{equation}\ignorespacesafterend%
}
\def\snug#1{\vspace*{-#1\baselineskip}}
\begin{document}
\begin{algneqn}    
F_L^{\rightarrow}   & =     q ( E_{eFeld}^{\rightarrow} + v^{\rightarrow} \times B^{\rightarrow} )
    \end{algneqn}

much text

    \begin{algneqn}
    F_{Lx}  & =     q ( E_{eFeld} + v_{gx} * B )
    \end{algneqn}

    little text

    \begin{algneqn}
    T   & =     F_{L1} - F_{L2}                                         \\
        & =     q ( E_{eFeld} + v_{g1} * B - E_{eFeld} - v_{g2} * B )   \\
        & =     q*B ( v_{g1} - v_{g2} )         
    \end{algneqn}                     

    \subsection{new subsection}

    very little text

    \begin{algneqn}
    P_{Photon}  & =     hf * nAc                \\
                & =     \dfrac{E_{Photon}}{t}    
    \end{algneqn}

    more text

    \begin{algneqn}
    F_{0}       & =     2nhfA               \\
                & =     \dfrac{2 P_{Photon}}{c}  
    \end{algneqn}
\end{document}

enter image description here

David Carlisle
  • 757,742