1

I'm trying to align a short equation and a long one.

enter image description here

Could you explain why the highlighted parts are not properly aligned?

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\left\{
\begin{aligned}
d x_t^i &= v_t^i d t, \\
\begin{split}
d v_t^i &= - (\nabla U (X_t^{i, n}) - \nabla U (\bar X_t^i)) d t \\
& \qquad + \bigg [ \bigg ( \frac{1}{n} \sum_{j=1}^n K (X_t^{i, n} - X_t^{j, n}) \bigg )^m - (K* \mu_t)^m (\bar X_t^i) \bigg ] d B_t^i. 
\end{split}
\end{aligned}
\right.
\]

\end{document}
4
  • you have a two row aligment the second row has no & just a nested split on the left hand side and an empty right hand side so the right edge of the split aligns with right edge of dx_t^i above. remove the split so all three rows in one aligned Mar 30, 2023 at 13:31
  • Package amsmath Warning: Cannot use 'split' here; trying to recover with 'aligned' on input line 12. Shouldn't it be alright if you don't use the split environment? Also I'd align the equations after the =, i.e. ... ={}& ... Mar 30, 2023 at 13:32
  • @DavidCarlisle In that way, I could not label the whole long equation...
    – Akira
    Mar 30, 2023 at 13:39
  • you have no labels anyway. \[ is unnumbred, and aligned and split do not make labeled rows, just subterms like array Mar 30, 2023 at 14:03

3 Answers 3

3

The whole line will get a single equation number (if you decide to have it numbered), so I personally don't see any (too important) reason why you should use split here. You should get the desired output by the following.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \left\{
    \begin{aligned}
        d x_t^i ={}& v_t^i d t, \\
        d v_t^i ={}& - (\nabla U (X_t^{i, n}) - \nabla U (\bar X_t^i)) d t \\
        & + \biggl [ \biggl ( \frac{1}{n} \sum_{j=1}^n K (X_t^{i, n} - X_t^{j, n}) \biggr )^m - (K* \mu_t)^m (\bar X_t^i) \biggr ] d B_t^i.
    \end{aligned}
    \right.
\]
\end{document}

Result

I deliberately changed the position of alignment to be after the equal sign, such that - and + are aligned.

Personally I'd also like to have the exponent after the biggr parenthesis to be closer to the parenthesis, so I'd prefer \biggr)^{\mkern-3mu m} or similar.

3
  • In thaisway, I could not label the whole long equation...
    – Akira
    Mar 30, 2023 at 13:44
  • Correct me if I'm wrong, but I think you can't label the second equation individually. If you replace \[...\] by \begin{equation}...\end{equation} the whole thing will get a single label Mar 30, 2023 at 13:54
  • Please, use \biggl and \biggr.
    – egreg
    Mar 30, 2023 at 19:32
4

You can use the IEEEeqnarraybox environment from the IEEEtrantools package. Its usage is somewhat like tabular environment. Here is a helpful documentation of the environment.

o/p

\documentclass{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}
\begin{document}
\[
\left\{
\begin{IEEEeqnarraybox}[][c]{rCl}
    d x_t^i &=& v_t^i d t, \\
    d v_t^i &=& - (\nabla U (X_t^{i, n}) - \nabla U (\bar X_t^i)) d t \\
            & & \negmedspace{} + \bigg [ \bigg ( \frac{1}{n} \sum_{j=1}^n K (X_t^{i, n} - X_t^{j, n}) \bigg )^m - (K* \mu_t)^m (\bar X_t^i) \bigg ] d B_t^i.\\
\end{IEEEeqnarraybox}
\right.
\]
\end{document}
2
  • Is there a reason to use {} before +, but not before - in the line above? Anyway, +1. Mar 30, 2023 at 15:38
  • @Οὖτις Otherwise, + is treated as a unary operator and the spacing is not consistent. Btw, should have used a \negmedspace to align the + with - correctly.
    – Imran
    Mar 30, 2023 at 17:32
4

split can only be used at the top level of equation or align (in the latter case only one alignment point in the outer align is allowed).

Using split inside aligned is an error and LaTeX tells you.

Just use a single aligned.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\left\{
\begin{aligned}
dx_t^i &= v_t^i \,dt, \\
dv_t^i &= - (\nabla U (X_t^{i, n}) - \nabla U (\bar X_t^i)) \,dt \\
       &\hphantom{={}}+
        \biggl[
          \biggl(
            \frac{1}{n} \sum_{j=1}^n K (X_t^{i, n} - X_t^{j, n})
          \biggr)^{\!m}
          - (K* \mu_t)^m (\bar X_t^i)
        \biggr] \,dB_t^i.
\end{aligned}
\right.
\]

\end{document}

Note that you should use \biggl for opening and \biggr for closing delimiters. Also, differentials should be preceded by \, if there's something before them.

It's better if you add \! in the exponent to a \biggr), so there's less space between them.

With \hphantom{={}} we get the exact space of the = sign in the upper line.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .