0

I have the formula

enter image description here

which I create with the code

\begin{align}
\WKernSub[\x]{sub} &\defas \bigsumshort \sum_{j=1\ |\ j\in\J}^{\card\Ob} \mhsp \frac{\massSub[j]{subA}}{\sqrt{ (2\m\pi\m\gwp)^{\nbFeat} }} \m \exp{ \frac{    \left(\x-\ob[j]\right)^\trnsp \m \left(\x-\ob[j]\right)   }{-2 \m \gwp} }  \mhspE,
\end{align}
\begin{align}
\J = \big\{\mhsp l \mhsp\big|\mhsp      &(  \ob\in\Obrd \AND l=i  ) \\
                                    \OR &(  \ob\in\Obru \AND \ob[l]\in\Obvd \AND \ob[l]\primderL\ob[i]  ) \mhsp\big\}  \mhspE,  \nn
\end{align}
\begin{align}
\WFctSub[\x]{sub} &\defas \bigsumshort \sum_{j=1\ |\ \ob[j]\in\Obr}^{\card\Ob} \WKernSub[\x]{sub} \label{eq:WKernSub}
\end{align}

What I would like is, to have the formulas aligned such, that the = and := are aligned. I do not want to have the alignment of the second formula touched. I did checkout Alignment across nested aligned environments, but I was not able to transfer this to my problem and Multiple aligning symbols. I don't want to "open" a new column for alignments.

How can I achieve this?

A minimal working example would be (other symbols):

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
W_{sub,i} &= asdf
\end{align}

\begin{align}
J = \big\{ l \quad\big|\quad    &(  o \in O ) \nonumber\\
                    \vee\quad   &(  o \in O \wedge o \in O  ) \big\}  , \nonumber
\end{align}

\begin{align}
W_{sub} &= some long formula without any meaning
\end{align}

\end{document}

resulting in

enter image description here

  • I see no formula 0.3 in the top picture. – egreg Sep 28 '17 at 12:24
  • note that despite the "resulting in", the image presumably was not made from the posted code (equation numbers formatted differently and wider text block) – David Carlisle Sep 28 '17 at 12:36
  • @egreg: Sorry, typo. I corrected it. – Make42 Sep 28 '17 at 12:44
  • an align that contains only one line is never going to align with anything else. only when multiple lines are present in an align (or alignat) environment are they going to interact. – barbara beeton Sep 28 '17 at 12:46
  • @barbarabeeton: Yes, and I would like to know how to do it. Simply putting everything into the align does not work, because I need multiple &s. I am just trying to explain, what I want, I am not claiming that I would expect this to be the answer. – Make42 Sep 28 '17 at 12:49
1

this is a kludge. it would have been much easier had you provided the definitions of the macros you used. the definitions and other coding here is just an approximation.

like david's answer, this nests an aligned block within the main alignment. the definition of the := is jiggered a bit to improve its alignment relative to that of the simple = signs.

\documentclass[leqno]{article}
\usepackage{mathtools}
\usepackage{bm}

\newcommand{\card}{\#}
\newcommand{\defas}{\;\mathrel{\!\!{:}{=}\,}}
\newcommand{\bigsumshort}{}
\newcommand{\gwp}{\omega}
\newcommand{\J}{\mathcal{J}}
\newcommand{\Ob}{\mathcal{O}}
\newcommand{\Obr}{\mathcal{O}_{\mathrm{r}}}
\newcommand{\Obrd}{\mathcal{O}_{\mathrm{rd}}}
\newcommand{\Obru}{\mathcal{O}_{\mathrm{ru}}}
\newcommand{\ob}{\bm{o}_{i}}
\newcommand{\m}{\cdot}
\newcommand{\mhsp}{}
\newcommand{\mhspE}{\;}
\newcommand{\massSub}[1]{m_{\mathrm{subA,v,#1}}}
\newcommand{\nbFeat}{F}
\newcommand{\trnsp}{\top}
\newcommand{\x}{\bm{x}}

\begin{document}

\begin{align}
\mathbf{W}_{\mathrm{sub}j} (\bm{x})
 &\defas \bigsumshort \sum_{j=1\ |\ j\in\J}^{\card\Ob} \mhsp
  \frac{\massSub{j}}{\sqrt{ (2\m\pi\m\gwp)^{\nbFeat} }} \m
  \exp \left( \frac{    \left(\x-\ob[j]\right)^\trnsp \m \left(\x-\ob[j]\right)   }{-2 \m \gwp} \right) \mhspE,\\
%
J &= \bigl\{ l \; \bigl| \;
           \begin{aligned}[t]
                  &( \ob \in \Obrd \wedge l = i ) \\
               \mathllap{\vee\,}   &( \ob \in \Obru \wedge \ob \in \Obrd
               \wedge \ob \leftarrow \ob  ) \bigr| \bigr\}  ,
           \end{aligned} \nonumber\\
%\J &= \big\{\mhsp l \mhsp\big|\mhsp      &(  \ob\in\Obrd \AND l=i  ) \\
%%                                    \OR &(  \ob\in\Obru \AND \ob[l]\in\Obvd \AND \ob[l]\primderL\ob[i]  ) \mhsp\big\}  \mhspE,  \nn\\
%
\mathbf{WF}_{\mathrm{sub}}(\x) &\defas \bigsumshort \sum_{j=1\ |\ \ob[j]\in\Obr}^{\card\Ob} \mathbf{W}_{\mathrm{sub}j}(\x) \label{eq:WKernSub}\\
%
W_{sub,i} &= asdf\\
%
W_{sub} &= some long formula without any meaning
\end{align}

\end{document}

output of example code

  • the problem of fitting this into the narrow width of a two-column page is left as an exercise to the reader. – barbara beeton Sep 28 '17 at 14:00
  • Easier than some of Knuth's exercises in The Art of Computer Programming ;o) – Bernard Sep 28 '17 at 14:25
  • The commands to create the symbols are hundreds of lines of code. They are not simply created with single command, but build on further commands, which build on further commands, etc. My Symbols.sty file has 1057 lines of code. Its the only way to handle the number of symbols I have. – Make42 Sep 28 '17 at 17:17
3

I's use a nested aligned (It is best never to have one math display following another, TeX doesn't really try to space that correctly)

enter image description here

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
W_{\mathrm{sub},i} &= asdf\\
&\begin{aligned}
J = \big\{ l \quad\big|\quad    &(  o \in O ) \nonumber\\
                    \vee\quad   &(  o \in O \wedge o \in O  ) \big\}  , \nonumber
\end{aligned}\\
W_{\mathrm{sub}} &= some long formula without any meaning
\end{align}

\end{document}
  • now the J is aligned with the other two =. Can we align them on the =s? – Make42 Sep 28 '17 at 12:46
  • @Make42 well yes of course, just move the J= before the &\begin{aligned} but I read your question as saying explicitly that you didn't want the middle terms aligned with the W_..= terms. – David Carlisle Sep 28 '17 at 12:53
  • That was a misunderstanding. Probably because of the typo I corrected. – Make42 Sep 28 '17 at 13:14

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.