Writing a PDE spread over multiple lines with elements description in LaTeX [closed] - latex

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
for my master thesis I have to include a long PDE which has to be distributed over multiple lines for space and understanding purposes. Each term has its own description.
The final goal is to reproduce the equation in the pictureturbulent energy equation.
My LaTeX code (overleaf) is the following:
\begin{multline}
%right-end side
%first term
\left.\rho c\left(\frac{\partial\overline{T}}{\partial t}+\overline{u}\frac{\partial\overline{T}}{\partial x}+\overline{v}\frac{\partial\overline{T}}{\partial y}+\overline{w}\frac{\partial\overline{T}}{\partial z}\right) \right\} \quad \text{advection}\\
%left-end side
%first term
=\left.\lambda\left(\frac{\partial^2\overline{T}}{\partial x^2}+\frac{\partial^2\overline{T}}{\partial x^2}+\frac{\partial^2\overline{T}}{\partial x^2}\right) \right\} \quad \text{diffusion}\\
%second term
\left.-\rho c\left(\frac{\partial\overline{u^\prime T^\prime}}{\partial x}+\frac{\partial\overline{v^\prime T^\prime}}{\partial y}+\frac{\partial\overline{w^\prime T^\prime}}{\partial z}\right) \right\} \quad \text{turbulent heat transport} \\
%third term
+\left.\mu\left(2\left(\frac{\partial\overline{u}}{\partial x}\right)^2+2\left(\frac{\partial\overline{v}}{\partial y}\right)^2+2\left(\frac{\partial\overline{w}}{\partial z}\right)^2 \\
+\left(\frac{\partial\overline{v}}{\partial z}+\frac{\partial\overline{w}}{\partial y}\right)^2\right) \\ \right\} \quad \text{direct dissipation}
%fourth term
+\left.\mu\left[2\bar{\left(\frac{\partial u\prime}{\partial x}\right)^2}+2\bar{\left(\frac{\partial v\prime}{\partial y}\right)^2}+2\bar{\left(\frac{\partial w}{\partial z}\right)^2} \\
+\bar{\left(\frac{\partial u\prime}{\partial y}+\frac{\partial v\prime}{\partial x}\right)^2}+\bar{\left(\frac{\partial u\prime}{\partial z}+\frac{\partial w\prime}{\partial x}\right)^2}\\
+\bar{\left(\frac{\partial v\prime}{\partial z}+\frac{\partial w\prime}{\partial y}\right)^2}\right] \right\} \quad \text{turbulent dissipation}
\end{multline}
Differently from the example in the figure, I also have to develop the last term.
The code that I've written still miss the alignment of the names of the different terms and if a single term of the PDE is distributed over multiple lines, then the curly brackets are not represented.
Can anyone please help me? Thanks.

Please, always provide the full code. It is particularly difficult to track issues in LaTeX code without having all the details.
I changed environment to align* and added a few inner aligned environments. The former splits lines into both equation and annotation parts.
All the right braces are a little tricky but you can always scale \left.\right. manually using an arbitrary vertical bar. If you change equations you might need to reapply the size. \left(...\right) macros are not recommended as they introduce many issues including inconsistent spacing and scaling. The \mleftright package corrects some of them but it is still better to use \Bigl[ or \Biggr\} etc.
The code
\documentclass{article}
\usepackage{mathtools}
\newlength\lefteqskip
\begin{document}
\lefteqskip3.5em
\begin{align*}
%right-end side
%first term
\mathrlap{\rho c
\left(
\frac{\partial\overline{T}}{\partial t}
+\overline{u}\frac{\partial\overline{T}}{\partial x}
+\overline{v}\frac{\partial\overline{T}}{\partial y}
+\overline{w}\frac{\partial\overline{T}}{\partial z}
\right)}
\phantom{={}}
%\hspace{0.5\lefteqskip} % indents LHS
&&&\biggr\} \quad \text{advection} \\
%left-end side
%first term
={}&{}\lambda
\left(
\frac{\partial^2\overline{T}}{\partial x^2}
+\frac{\partial^2\overline{T}}{\partial x^2}
+\frac{\partial^2\overline{T}}{\partial x^2}
\right)
&&\biggr\} \quad \text{diffusion}\\
%second term
&{}-\rho c
\left(
\frac{\partial\overline{u^\prime T^\prime}}{\partial x}
+\frac{\partial\overline{v^\prime T^\prime}}{\partial y}
+\frac{\partial\overline{w^\prime T^\prime}}{\partial z}
\right)
&&\biggr\} \quad \text{turbulent heat transport} \\
%third term
&{}
\begin{aligned}
&{}+\mu\left(
2\left(
\frac{\partial\overline{u}}{\partial x}
\right)^2
+ 2\left(
\frac{\partial\overline{v}}{\partial y}
\right)^2\right. \\
&\left.\hspace{\lefteqskip}
{}+ 2\left(
\frac{\partial\overline{w}}{\partial z}
\right)^2
+ \left(
\frac{\partial\overline{v}}{\partial z}
+\frac{\partial\overline{w}}{\partial y}
\right)^2
\right)
\end{aligned}
&&\hspace{-3pt}
\left.\rule[-7.5ex]{0pt}{15ex}\right\}
\quad
\text{direct dissipation} \\
% % %fourth term
&\begin{aligned}
&{}+\mu\left[
2\bar{\left(
\frac{\partial u\prime}{\partial x}
\right)^2}
+2\bar{\left(
\frac{\partial v\prime}{\partial y}
\right)^2}
\right. \\
&\hspace{\lefteqskip}
+ 2\bar{\left(
\frac{\partial w}{\partial z}
\right)^2}
+ \bar{\left(
\frac{\partial u\prime}{\partial y}
+\frac{\partial v\prime}{\partial x}
\right)^2} \\
&\left.\hspace{\lefteqskip}
+\bar{\left(
\frac{\partial u\prime}{\partial z}
+\frac{\partial w\prime}{\partial x}
\right)^2}
+\bar{\left(
\frac{\partial v\prime}{\partial z}
+\frac{\partial w\prime}{\partial y}
\right)^2}
\right]
\end{aligned}
&&\hspace{-3pt}
\left.\rule[-11ex]{0pt}{22ex}\right\}
\quad
\text{turbulent dissipation}
\end{align*}
\end{document}

Related

How do I change mode in cases LaTeX

When I write a \prod in a cases, the \prod is like if it was in inline mode.
\mathbb{P} : \left\{ \forall n \in \mathbb{N} \Big| \nexists d \in \mathbb{N} \setminus \{1; n\} : d|n \right\}\\
\mathbb{P}_n \subset \mathbb{P} \times \mathbb{N}^* :
\begin{cases}
\left( \prod_{(k, m) \in \mathbb{P}_n} k^m \right ) = n\\
\forall (k; m) \in \mathbb{P}_n, \nexists (k'; m') \in \mathbb{P}_n \setminus \{(k, m)\}:k=k'
\end{cases}\\
Turns out it is in the amsmath manual after all (page 9):
cases is set in \textstyle. If \displaystyle is wanted, it must be requested explicitly; mathtools provides a dcases environment for this purpose.
See the mathtools manual:
Using the dcases environment you get the same output as with cases except that the rows are set in display style.
So this should work (untested though):
\usepackage{mathtools}
...
\begin{dcases}
\left( \prod_{(k, m) \in \mathbb{P}_n} k^m \right ) = n\\
\forall (k; m) \in \mathbb{P}_n, \nexists (k'; m') \in \mathbb{P}_n \setminus \{(k, m)\}:k=k'
\end{dcases}

Is there a way to fix the alignment of the ordered list in RMarkdown?

The placement of my ordered list appears in the middle instead of at the top. Is there any way to make it so the a) is aligned at the first line of the equation?
This is my code:
a)
$\begin{aligned}
\hat{y} &= (\overline{x_1} - \overline{x_2})'S^{-1}_{pooled}x \\
&= \left(\begin{bmatrix}3\\6\end{bmatrix}-\begin{bmatrix}5\\8\end{bmatrix}\right)'\begin{bmatrix}1&1\\1&2\end{bmatrix}^{-1}\begin{bmatrix}x_1\\x_2\end{bmatrix} \\
&= \begin{bmatrix}-2&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix} \\
&= -2x_1
\end{aligned}$
You can add another set of $ signs; one at the beginning and the other at the end.
a)
$$\begin{aligned}
\hat{y} &= (\overline{x_1} - \overline{x_2})'S^{-1}_{pooled}x \\
&= \left(\begin{bmatrix}3\\6\end{bmatrix}-\begin{bmatrix}5\\8\end{bmatrix}\right)'\begin{bmatrix}1&1\\1&2\end{bmatrix}^{-1}\begin{bmatrix}x_1\\x_2\end{bmatrix} \\
&= \begin{bmatrix}-2&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix} \\
&= -2x_1
\end{aligned}$$
Quoting the accepted answer here, the difference between the 2 is:
$$ will produce a block element (a paragraph) while $ will produce an inline element. Thus, $$ is often used for equations.

How do I write $ad-bc=1$ below $a,b,c,d \in \mathbb{Z}$?

\Gamma=\Big\lbrace
\begin{pmatrix}
a&b\\c&d
\end{pmatrix}: a,b,c,d \in \Z , ad-bc=1
\Big\rbrace
I know that "substack" does it but then the formulas are too small.
You could use \underset{<a>}{<b>} to obtain <a> below <b>.
\Gamma=\Big\lbrace
\begin{pmatrix}
a&b\\c&d
\end{pmatrix}:
\underset{ad-bc=1}{a,b,c,d \in \mathbb{Z}}
\Big\rbrace

Latex displaying this error missing $ inserted [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
begin{table}[h]
\centering
\begin{tabular}{c p{5cm} c}\hline
Attribut & Description & Equation \\ \hline
$E$ & The set of objects that can't be distinguished from each other based on the available attributes & Let $P \subseteq A$ ,
E(P) = \{\ (x, y) \in U^2 : \foralla P, a(x) = a(y) \}\ \\
$ \beta $& Admissible error rate\\
$K$ & Grade level
\end{tabular}
\end{table}
as I'm new to latex, when i use previous code i get this error "missing $ inserted" in the line E(P) = {\ (x, y) \in U^2 : \foralla P, a(x) = a(y) }\ \
can anyone help me with this error.
Well, you are missing an $ :) The equation E(P) ... must be typeset in math mode:
\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
\begin{tabular}{c p{5cm} c}\hline
Attribut & Description & Equation \\ \hline
$E$ & The set of objects that can't be distinguished from each other based on the available attributes & Let $P \subseteq A$ ,
$E(P) = \{\ (x, y) \in U^2 : \forall P, a(x) = a(y) \}$ \\
$ \beta $& Admissible error rate\\
$K$ & Grade level
\end{tabular}
\end{document}
Also, please make sure you include a complete and compilable document with the minimum of packages and definitions necessary to reproduce the problem.

Latex AMS align / Align multiple "=", too much space

I'd like to align some equations in Latex using the AMS packages. Each equation has two equal signs that need to be aligned. So something in the line of
A = B = C
D = E = F
I've tried using the align-environment like this
\begin{align}
A &= B &= C \\
D &= E &= F
\end{align}
This works in principle (it aligns), however it adds ridiculously large spaces before the second equal sign in each line.
But I just want the line to runs as if there was no additional alignment tab. Only when I replace for example "B" by "BBB" I want the equal sign before "F" to shift to right the exact amount of space.
Could anyone help me out on that one? It's kind of driving me crazy since I don't get the idea of that strange behavior and I just can't find any solution. Maybe alignat could help, but I don't really get how that environment works or in how it differs from normal align.
Cheers,
Oliver
This should work:
\begin{alignat}{2}
A &= B & &= C \\
D &= E & &= F
\end{alignat}
From ams guide:
A variant environment alignat allows
the horizontal space between equations
to be explicitly specified. This
environment takes one argument, the
number of “equation columns”: count
the maximum number of &s in any row,
add 1 and divide by 2.
Its not exactly intended for what you are trying to do, but since align insists on adding space...
The idea behind align is:
l&=r & l&=r \\
l&=r & l&=r
One '&' per function, and a '&' between functions.
I would hope there is a better solution though.
(6½ to 8 years later)
What about using array with a custom separator?
\begin{array}{r#{\ }c#{\ }l}
A &= B &= C \\
D &= E &= F
\end{array}
What about the below? They produce aligned "=" signs for me...
\begin{tabular}{lllll}
A & = & B & = & C \\
D & = & E & = & F \\
\end{tabular}
\begin{tabular}{lllll}
A & = & BBB & = & C \\
D & = & E & = & F \\
\end{tabular}

Resources