1

Good Evening

I'm new to Latex. I am writing the decomposition of an equation about turbulent motion. I have problems with alignment on the left and with numbering of the equations. I do not understand why the alignment direction can not be chosen in the align method. maybe someone can help me to understand what I'm neglecting? For the last two examples I followed the indications of this post

Large formula in align

I have used various conditions, I put the three codes with the results:

\begin{align} % N-S Decomposition 1 
\bar{u}_{i,t}+u^{\prime}_{i,t} +{({\bar{u}}_{j}+{u^{\prime}_{j}})}({\bar{u}}_{i}+u^{\prime}_{i})_{,j} =\\
\nonumber
-\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}^{\prime}){g^{\prime}}z_{,i}
    -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}^{\prime}_{,i})
    +2\nu({\bar{e}_{ij}+e^{\prime}_{ij})_{,j}} 
\end{align}

Prima Immagine

\stackMath
\def\stackalignment{l}
\begin{equation}
\stackanchor[10pt]{\displaystyle%
    \bar{u}_{i,t}+u^{\prime}_{i,t} +{({\bar{u}}_{j}+{u^{\prime}_{j}})}({\bar{u}}_{i}+u^{\prime}_{i})_{,j} =\\ 
}{\quad\quad\quad\quad\quad\displaystyle
-\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}^{\prime}){g^{\prime}}z_{,i}
-\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}^{\prime}_{,i})
+2\nu({\bar{e}_{ij}+e^{\prime}_{ij})_{,j}} 
} 
\end{equation}

Seconda Immagine

in this code, everything is marked in red as if it did not recognize the code, but it also creates the pdf

\stackMath
\def\stackalignment{l}
\stackanchor[10pt]{\displaystyle%
\overline{u^{\prime}_{i}u^{\prime}_{i,t}}
+\overline{u^{\prime}_{i}\bar{u}_{j}u^{\prime}_{i,j}}
+\overline{u^{\prime}_{i}u^{\prime}_{j}u^{\prime}_{i}\bar{u}_{i,j}}
+\overline{u^{\prime}_{i}u^{\prime}_{j}u^{\prime}_{i,j}} =
    }{\quad\quad\quad\quad\quad\quad\quad\quad\quad\displaystyle
-\frac{1}{\rho_{0}}\overline{\rho^{\prime}u^{\prime}_{i}}{g^{\prime}}z_{,i}
-\frac{1}{\rho_{0}}\overline{p^{\prime}_{,i}u^{\prime}_{i}}
+2\nu\overline{{{e}^{\prime}_{ij,j}}u^{\prime}_{i}}
-\overline{\overline{(u^{\prime}_{i}u^{\prime}_{j})}_{,j} u^{\prime}_{i}}
    } \\

Terza Immagine for me the red color code is set for: command not recognized Quarta immagine

%----------------------------------------------------------

I can not give an answer individually because I find all your solutions very interesting, very eustive. this afternoon I will look at the code more calmly and recompile. if I find any difficulty I will write. I would like to request information from the third code. this belongs to the usepackage {stackengine} library. I would like to know why latex tells me: command not recognized

I solved the problem of numbering. is bound to\numberwithin{equation}{chapter} .I found this command interesting and I will try to use it.

  • 1
    the red isn't a warning from latex that is just that your editor doesn't know of that package so it isn't a problem. unrelated but you do not need to write u^{\prime} simply u' will make identical output – David Carlisle Feb 22 '18 at 18:10
  • 1
    it isn't clear what alignment you want but align should only be used if you want to align points (marked with &) on the the different rows. – David Carlisle Feb 22 '18 at 18:11
  • @DavidCarlisle I want the formula to be left-aligned. I would like to understand if the second code is correct – Antonio Feb 22 '18 at 18:18
  • if you want all equations left aligned just use [fleqn] option to your documentclass (it is better if you always post examples as complete documents that can be tested rather than fragments as above) – David Carlisle Feb 22 '18 at 19:14
  • if you want to ask if some code is correct it is best to post a test docuemnt (which for example would show any packages assumed) the markup in both cases is far more complicated than needed, but it isn't really clear what layout you want – David Carlisle Feb 22 '18 at 19:54
4

Here are three possibilities:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{align} % N-S Decomposition 1
 & \bar{u}_{i,t}+u^{\prime}_{i,t} +{({\bar{u}}_{j}+{u^{\prime}_{j}})}({\bar{u}}_{i}+u^{\prime}_{i})_{,j} =\\
\nonumber
 & {-}\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}^{\prime}){g^{\prime}}z_{,i}
 -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}^{\prime}_{,i})
 +2\nu({\bar{e}_{ij}+e^{\prime}_{ij})_{,j}}
\end{align}
\bigskip

\begin{equation}
\begin{aligned} % N-S Decomposition 1
 & \bar{u}_{i,t}+u^{\prime}_{i,t} +{({\bar{u}}_{j}+{u^{\prime}_{j}})}({\bar{u}}_{i}+u^{\prime}_{i})_{,j} =\\
 & {-}\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}^{\prime}){g^{\prime}}z_{,i}
 -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}^{\prime}_{,i})
 +2\nu({\bar{e}_{ij}+e^{\prime}_{ij})_{,j}}
\end{aligned}
\end{equation}
\bigskip

\begin{equation}
\begin{multlined} % N-S Decomposition 1
  \bar{u}_{i,t}+u^{\prime}_{i,t} +{({\bar{u}}_{j}+{u^{\prime}_{j}})}({\bar{u}}_{i}+u^{\prime}_{i})_{,j} =\\
  {-}\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}^{\prime}){g^{\prime}}z_{,i}
    -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}^{\prime}_{,i})
    +2\nu({\bar{e}_{ij}+e^{\prime}_{ij})_{,j}}
\end{multlined}
\end{equation}

\end{document}

enter image description here

3

only first equation:

enter image description here

with using split environment:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{equation} % N-S Decomposition 1
\begin{split}
& \bar{u}_{i,t}+u'_{i,t} +{({\bar{u}}_{j}+{u'_{j}})}({\bar{u}}_{i}+u'_{i})_{,j} = \\
& {-}\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}'){g'}z_{,i}
        -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}'_{,i})
        +2\nu({\bar{e}_{ij}+e'_{ij})_{,j}}
\end{split}
    \end{equation}    
\end{document}
  • @Mico, thank you . corrected. difference is evident :-) – Zarko Feb 23 '18 at 11:49
1

The first two-line formula below reproduces your first align example, while (a) adding alignment points (&) at the start of each line and (b) getting rid of quite a few redundant pairs of curly braces and replacing all instances of ^{\prime} with '. Note that I encased the first - (minus) symbol of the second line in curly braces, so that LaTeX treats it as a unary rather than as a binary operator.

The second formula applies three minor tweaks: the = symbol is moved to the start of the second line, the second line is indented relative to the first (via a \quad directive), and the vertical separation between the lines is increased slightly. Observe that because the second line now starts with a = symbol, it's no longer necessary to do anything special with the subsequent - symbol in order for it to be treated as a unary operator.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align' environment 
\begin{document}

\begin{align} 
&\bar{u}_{i,t}+u'_{i,t} +(\bar{u}_{j}+u'_{j})(\bar{u}_{i}+u'_{i})_{,j} =\\
&{-}\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}')g'z_{,i}
    -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}'_{,i})
    +2\nu(\bar{e}_{ij}+e'_{ij})_{,j}  \nonumber
\end{align}

\begin{align} 
&\bar{u}_{i,t}+u'_{i,t} +(\bar{u}_{j}+u'_{j})(\bar{u}_{i}+u'_{i})_{,j} \\[1ex]
&\quad=-\frac{1}{\rho_{0}}(\bar{\tilde{\rho}}+\tilde{\rho}')g'z_{,i}
    -\frac{1}{\rho_{0}}(\bar{\tilde{p}}_{,i}+\tilde{p}'_{,i})
    +2\nu(\bar{e}_{ij}+e'_{ij})_{,j}  \nonumber
\end{align}

\end{document}
  • \multline could also be an option. – user94293 Feb 22 '18 at 18:37
  • @user94293 - multline might be an option for other two-line equations. However, for the present one, using a multline environment would produce a fairly substandard result. (Give it a try if you're skeptical about this claim.) – Mico Feb 22 '18 at 19:30
  • @Mico I had read that for a better compilation it was more appropriate to use {prime}. objectively I find ugly _ {\ tilde} _ {prime}, the first graphically should be smaller and more detached from the symbol. if the file is printed in small font, the job does not come out good. – Antonio Feb 23 '18 at 8:02
  • @Antonio - I don't know where you read that "for a better compilation it was more appropriate to use ^{]prime}". It's simply wrong. There's a lot of TeX-related disinformation (as well as all kinds of other disinformation, of course!) out there on the Internet. – Mico Feb 23 '18 at 8:14
  • 1
    @Mico - you are right. much misinformation. for this reason the best solution is to talk with you all. Thank you – Antonio Feb 23 '18 at 8:17
0

I can not give an answer individually because I find all your solutions very interesting, very exhaustive. This afternoon I will look at the code more calmly and recompile. Iif I find any difficulty I will write. I would like to request information from the third code. This belongs to the \usepackage{stackengine} library. I would like to know why latex tells me: command not recognized.

  • 1
    Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. - From Review – Bobyandbob Feb 23 '18 at 8:34
  • @Bobyandbob Ok. – Antonio Feb 23 '18 at 9:02

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.