So, I've been trying to create a flashcard of a (rather simple) mathematical proof I did on my own. Now I want to align the equals signs, and it seems to work up to 11 terms, but not more. This doesn't make any sense in my opinion and my mistake is probably somewhere else.
Here is the "code":
[latex\]\begin{align} \sigma \left(X\right) &= \sqrt{\sum_{k=0}^n \left(k - µ\right)^2 \cdot P\left(X=k\right)} \\
&= \sqrt{\sum_{k=0}^n \left(k^2 - 2kµ + µ^2\right) \cdot P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n \left(k^2 \cdot P\left(X=k\right) - 2kµ \cdot P\left(X=k\right) + µ^2\cdot P\left(X=k\right)\right)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P\left(X=k\right) + \sum_{k=0}^n - 2kµ \cdot P\left(X=k\right) + \sum_{k=0}^n µ^2\cdot P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P\left(X=k\right) + - 2µ \cdot \sum_{k=0}^n k \cdot P\left(X=k\right) + µ^2\cdot \sum_{k=0}^n P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n \left( k^2 \cdot \binom{n}{k} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - 2n^2 p^2 + n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left( k^2 \cdot \binom{n}{k} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\left(k-1+1\right) \cdot \frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} + \frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \right) \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) + \sum_{k=0}^n \left(\frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) + np - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(n\cdot\left(n-1\right)\cdot\frac{(n-2)!}{\left(k-2\right)! \cdot \left(n-k\right)!} \cdot p^2 \cdot p^{k-2} \cdot \left(1-p\right)^{(n-2)-(k-2)} \right) + np - n^2 p^2} \\
&=\sqrt{n\cdot\left(n-1\right)\cdot p^2 \cdot \sum_{k=2}^n \left( \binom{n-2}{k-2} \cdot p^{k-2} \cdot \left(1-p\right)^{(n-2)-(k-2)} \right) + np - n^2 p^2} \\
&=\sqrt{n\cdot\left(n-1\right)\cdot p^2 \cdot \sum_{k=0}^{n-2} \left( \binom{n-2}{k} \cdot p^{k} \cdot \left(1-p\right)^{(n-2)-k} \right) + np - n^2 p^2} \\
&=\sqrt{n\cdot\left(n-1\right)\cdot p^2 \cdot \left(p + 1-p\right)^{n-2} + np - n^2 p^2} \\
&=\sqrt{n\cdot\left(n-1\right)\cdot p^2 + np - n^2 p^2} \\
&=\sqrt{\left(n^2 - n\right)\cdot p^2 + np - n^2 p^2} \\
&=\sqrt{n^2 p^2 - n p^2 + np - n^2 p^2} \\
&=\sqrt{- n p^2 + np} \\
&=\sqrt{n\cdot p\cdot\left(1-p\right)}\end{align} \[/latex]
[latex] q.e.d. [/latex]
Here is the same code without \left and \right to make it more readable:
[latex\]\begin{align} \sigma (X) &= \sqrt{\sum_{k=0}^n (k - µ)^2 \cdot P(X=k)} \\
&= \sqrt{\sum_{k=0}^n (k^2 - 2kµ + µ^2) \cdot P(X=k)} \\
&=\sqrt{\sum_{k=0}^n (k^2 \cdot P(X=k) - 2kµ \cdot P(X=k) + µ^2\cdot P(X=k))} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P(X=k) + \sum_{k=0}^n - 2kµ \cdot P(X=k) + \sum_{k=0}^n µ^2\cdot P(X=k)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P(X=k) + - 2µ \cdot \sum_{k=0}^n k \cdot P(X=k) + µ^2\cdot \sum_{k=0}^n P(X=k)} \\
&=\sqrt{\sum_{k=0}^n ( k^2 \cdot \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k} ) - 2n^2 p^2 + n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ( k^2 \cdot \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ((k-1+1) \cdot \frac{n!}{(k-1)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ((\frac{n!}{(k-2)! \cdot (n-k)!} + \frac{n!}{(k-1)! \cdot (n-k)!} ) \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n (\frac{n!}{(k-2)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) + \sum_{k=0}^n (\frac{n!}{(k-1)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n (\frac{n!}{(k-2)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) + np - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n (n\cdot(n-1)\cdot\frac{(n-2)!}{(k-2)! \cdot (n-k)!} \cdot p^2 \cdot p^{k-2} \cdot (1-p)^{(n-2)-(k-2)} ) + np - n^2 p^2} \\
&=\sqrt{n\cdot(n-1)\cdot p^2 \cdot \sum_{k=2}^n ( \binom{n-2}{k-2} \cdot p^{k-2} \cdot (1-p)^{(n-2)-(k-2)} ) + np - n^2 p^2} \\
&=\sqrt{n\cdot(n-1)\cdot p^2 \cdot \sum_{k=0}^{n-2} ( \binom{n-2}{k} \cdot p^{k} \cdot (1-p)^{(n-2)-k} ) + np - n^2 p^2} \\
&=\sqrt{n\cdot(n-1)\cdot p^2 \cdot (p + 1-p)^{n-2} + np - n^2 p^2} \\
&=\sqrt{n\cdot(n-1)\cdot p^2 + np - n^2 p^2} \\
&=\sqrt{(n^2 - n)\cdot p^2 + np - n^2 p^2} \\
&=\sqrt{n^2 p^2 - n p^2 + np - n^2 p^2} \\
&=\sqrt{- n p^2 + np} \\
&=\sqrt{n\cdot p\cdot(1-p)}\end{align} \[/latex]
[latex] q.e.d. [/latex]
I don't know why ctrl + k (in StackOverflow) formats it in different ways, but if always used it this way in my code: [latex][/latex]
However, it shows just a blank line and under it "q.e.d." (code with \right and \left):
However, if I just write the first 11 lines, it works:
[latex\]\begin{align} \sigma \left(X\right) &= \sqrt{\sum_{k=0}^n \left(k - µ\right)^2 \cdot P\left(X=k\right)} \\
&= \sqrt{\sum_{k=0}^n \left(k^2 - 2kµ + µ^2\right) \cdot P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n \left(k^2 \cdot P\left(X=k\right) - 2kµ \cdot P\left(X=k\right) + µ^2\cdot P\left(X=k\right)\right)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P\left(X=k\right) + \sum_{k=0}^n - 2kµ \cdot P\left(X=k\right) + \sum_{k=0}^n µ^2\cdot P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P\left(X=k\right) + - 2µ \cdot \sum_{k=0}^n k \cdot P\left(X=k\right) + µ^2\cdot \sum_{k=0}^n P\left(X=k\right)} \\
&=\sqrt{\sum_{k=0}^n \left( k^2 \cdot \binom{n}{k} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - 2n^2 p^2 + n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left( k^2 \cdot \binom{n}{k} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\left(k-1+1\right) \cdot \frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} + \frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \right) \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) + \sum_{k=0}^n \left(\frac{n!}{\left(k-1\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n \left(\frac{n!}{\left(k-2\right)! \cdot \left(n-k\right)!} \cdot p^k \cdot \left(1-p\right)^{n-k} \right) + np - n^2 p^2} \end{align} \[/latex]
Here is the same code without \left and \right to make it more readable:
[latex\]\begin{align} \sigma (X) &= \sqrt{\sum_{k=0}^n (k - µ)^2 \cdot P(X=k)} \\
&= \sqrt{\sum_{k=0}^n (k^2 - 2kµ + µ^2) \cdot P(X=k)} \\
&=\sqrt{\sum_{k=0}^n (k^2 \cdot P(X=k) - 2kµ \cdot P(X=k) + µ^2\cdot P(X=k))} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P(X=k) + \sum_{k=0}^n - 2kµ \cdot P(X=k) + \sum_{k=0}^n µ^2\cdot P(X=k)} \\
&=\sqrt{\sum_{k=0}^n k^2 \cdot P(X=k) + - 2µ \cdot \sum_{k=0}^n k \cdot P(X=k) + µ^2\cdot \sum_{k=0}^n P(X=k)} \\
&=\sqrt{\sum_{k=0}^n ( k^2 \cdot \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k} ) - 2n^2 p^2 + n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ( k^2 \cdot \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ((k-1+1) \cdot \frac{n!}{(k-1)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n ((\frac{n!}{(k-2)! \cdot (n-k)!} + \frac{n!}{(k-1)! \cdot (n-k)!} ) \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n (\frac{n!}{(k-2)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) + \sum_{k=0}^n (\frac{n!}{(k-1)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) - n^2 p^2} \\
&=\sqrt{\sum_{k=0}^n (\frac{n!}{(k-2)! \cdot (n-k)!} \cdot p^k \cdot (1-p)^{n-k} ) + np - n^2 p^2} \end{align} \[/latex]
This is the output (code with \right and \left, without I just seems to work with 10 lines instead of 11):
I hope you can help me. However, I am a beginner in LaTeX, so I need a rather detailed explanation.
Related
I am trying to typeset the following equation in the align-evoirement
\begin{align}
t_2' &= t_2 + \frac{L/C} \\
t_1' &= t_1 + \frac{L + v\Delta t\cos\theta}{c} \\
t_2' - t_1' &= (t_2-t_1) + \frac{L-L-v\Delta t\cos\theta}{C} \\
\Delta t' &= \Delta t - \frac{v\Delta t \cos \theta}{c} \\
\Delta t' &= \Delta t \left(1-\frac{v\cos\theta}{c}\right) \\
\frac{1}{\nu} &= \frac{1}{\nu_0 \sqrt{1-\frac{v^2}{c^2}}}~\left(1-\frac{v\cos \theta {c}\right) \\
\nu &= \nu_0\frac{ \sqrt{1-\dfrac{v^2}{c^2}}}{1-\dfrac{v\cos \theta }{c}}
\end{align}
But when I tried this I got the following message:
[45]
! Missing } inserted.
<inserted text>
}
l.938 \end{align}
?
I copied the equations in Matcha (without the &), where it was perfectly working... I tried some things, but those did not seem to work...
Does anybody know what I did wrong?
At two occasions you write \frac{..} without the mandatary second argument. You must write \frac{...}{...} instead.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
t_2' &= t_2 + \frac{L}{C} \\
t_1' &= t_1 + \frac{L + v\Delta t\cos\theta}{c} \\
t_2' - t_1' &= (t_2-t_1) + \frac{L-L-v\Delta t\cos\theta}{C} \\
\Delta t' &= \Delta t - \frac{v\Delta t \cos \theta}{c} \\
\Delta t' &= \Delta t \left(1-\frac{v\cos\theta}{c}\right) \\
\frac{1}{\nu} &= \frac{1}{\nu_0 \sqrt{1-\frac{v^2}{c^2}}}~\left(1-\frac{v\cos \theta}{c}\right) \\
\nu &= \nu_0\frac{ \sqrt{1-\dfrac{v^2}{c^2}}}{1-\dfrac{v\cos \theta }{c}}
\end{align}
\end{document}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
\begin{tiny}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C & A -\textgreater $\sim$C & C -\textgreater $\sim$A & (A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A) & (B -\textgreater $\sim$C) -\textgreater ((A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabular}
\end{table}
\end{tiny}
\end{document}
Can anyone help me so that the table fits in LaTeX? It almost fits, but half of the last column part goes outiside the paper. I have already tried to add /small and /footnotesize, but it doesnt work.
Please have a look at http://betterposters.blogspot.de/2012/08/the-data-prison.html how to design nice looking tables
You could use a tabularx and let latex adjust the size:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\usepackage{tabularx}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
\begin{tiny}
\begin{table}[h]
\begin{tabularx}{\linewidth}{|l|l|l|l|l|l|l|l|X|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C & A -\textgreater $\sim$C & C -\textgreater $\sim$A & (A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A) & (B -\textgreater $\sim$C) -\textgreater ((A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabularx}
\end{table}
\end{tiny}
\end{document}
Just complementing the answer, if the table is very large, it's possible to rotate the sheet by using pdflscape:
\usepackage{pdflscape}
...
\begin{landscape}
(Your Table)
\end{landscape}
My solution:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
%\begin{tiny}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|l|l|p{20mm}|p{22mm}|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C %
& A -\textgreater $\sim$C & C -\textgreater $\sim$A %
& (A -\textgreater $\sim$C) \par /\textbackslash (C -\textgreater $\sim$A) %
& (B -\textgreater $\sim$C) \par -\textgreater ((A -\textgreater $\sim$C) \par %
/\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabular}
\end{table}
%\end{tiny}
\end{document}
I have only edited the alignment of the 8th and 9th column (p{20mm}|p{22mm}) and added three \par in the first cell in such columns (out of dollar signs, you're typing text in the cells).
Anyway the solution with tabularx by #samcarter is very good.
I need to finish a paper but i need to fix the equations formatting of a linear programming model. I am using the environment eqnarray and i almost have it formatted the way my advisor asked. This is a sample of i got 1. I need to align the right side of the equations to the left while aligning the left side to the right (the left side is OK). Does anyone know if there is a way to make this modification with the eqnarray environment?
This is part of the latex code that generated this image:
\begin{eqnarray}
\mbox{s. t.} \qquad \sum_{j \in V_{+1} | i \neq j} x_{ij} \quad = & 1 & \forall\, i \in C \label{eq2} \\
\sum_{j \in V_{+1} | i \neq j} x_{ij} \quad \leq & 1 & \forall\, i \in \{R \cup S\} \label{eq3} \\
\sum_{i \in V_{+1} | i \neq j} x_{ji} \quad = & \sum_{i \in V_{0} | i \neq j} x_{ij} & \forall\, j \in V \label{eq4} \\
\sum_{i \in \{C \cup R\}} y_{i} \quad \leq & O & \forall i \in R \label{eq27} \\
\sum_{j \in V_{0} | i \neq j} x_{ji} \quad \leq & M \cdot y_{i} & \forall i \in R \label{eq7} \\
\sum_{j \in V_{0} | h \neq j} x_{jh} \quad \leq & M \cdot y_{i} & \forall i \in R, h \in SK_{i} \label{eq8} \\
t_{j} \quad \geq & t_{i} + ( td_{ij} + s_{i} ) \cdot x_{ij} - M \cdot (1 - x_{ij}) & \forall i \in C_{0}, j \in V_{1} | i \neq j \label{eq9} \\
t_{j} \quad \geq & t_{i} + td_{ij} \cdot x_{ij} + ct \cdot x_{ij} - M \cdot (1 - x_{ij}) & \forall i \in \{R \cup SK_{h \in R}\}, j \in V_{1} | i \neq j \label{eq11}
\begin{eqnarray}
Thank you.
eqnarray environment will not compatible for multi column align for multiple equation. So i am using alignat enviornment.
\begin{alignat}{3}
\mbox{s. t.} \qquad \sum_{j \in V_{+1} | i \neq j} x_{ij} &= 1 &&\quad \forall\, i \in C\label{eq2} \\
\sum_{j \in V_{+1} | i \neq j} x_{ij} &\leq 1 &&\quad \forall\, i \in \{R \cup S\} \label{eq3} \\
\sum_{i \in V_{+1} | i \neq j} x_{ji} & =\sum_{i \in V_{0} | i \neq j} x_{ij} &&\quad \forall\, j \in V \label{eq4} \\
\sum_{i \in \{C \cup R\}} y_{i} &\leq O &&\quad \forall i \in R \label{eq27} \\
\sum_{j \in V_{0} | i \neq j} x_{ji} & \leq M \cdot y_{i} &&\quad \forall i \in R \label{eq7} \\
\sum_{j \in V_{0} | h \neq j} x_{jh} &\leq M \cdot y_{i} &&\quad \forall i \in R, h \in SK_{i} \label{eq8} \\
t_{j} &\geq t_{i} + ( td_{ij} + s_{i} ) \cdot x_{ij}\nonumber\\
&\quad{} - M \cdot (1 - x_{ij}) &&\quad \forall i \in C_{0}, j \in V_{1} | i \neq j \label{eq9} \\
t_{j} &\geq t_{i} + td_{ij} \cdot x_{ij} + ct \cdot x_{ij}\nonumber\\
&\quad{}- M \cdot (1 - x_{ij}) &&\quad \forall i \in \{R \cup SK_{h \in R}\}, j \in V_{1} | i \neq j \label{eq11}
\end{alignat}
I think you got this!
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 2 years ago.
Improve this question
I am a beginner in latex. I have the following piece of latex code. The code is working fine but I wish all the equality operators and the "if kflag=n" of each equation be aligned and written in one equation box with one equation counting number. How can it be done?
\begin{equation} %kflag=0
\left \{
\begin{array}{rl}
T =& (1-D)\sigma_{max,0}\times e^{1-\frac{\Delta_n}{\delta_n}}\times \frac{\Delta_n}{\delta_n}\\
K =& \frac{(1-D)\sigma_{max,0}}{\delta_n}\times e^{1-\frac{\Delta_n}{\delta_n}}\times (1-\frac{\Delta_n}{\delta_n})\\
\end{array}
\right.
\quad \text{if} \quad kflag=0
\end{equation}
\begin{equation} %kflag=1
\left \{
\begin{array}{rl}
T =& \alpha\sigma_{max,0}\times e^{1-\frac{\Delta_n}{\delta_n}}\times \frac{\Delta_n}{\delta_n}\\
K =& \frac{\alpha\sigma_{max,0}}{\delta_n}\times e^{1-\frac{\Delta_n}{\delta_n}}\times (1-\frac{\Delta_n}{\delta_n})\\
\end{array}
\right.
\quad \text{if} \quad kflag=1
\end{equation}
\begin{equation} %kflag=2
\left \{
\begin{array}{rl}
T =& (1-D)\sigma_{max,0}\times e^{1-\frac{\Delta_n}{\delta_n}}\times \frac{\Delta_n}{\delta_n}+T_{max}-\\
&(1-D)\sigma_{max,0}\times e\times\frac{\Delta_{max}}{\delta_n}+\\
&10\times \sigma_{max,0}\times e^{1-\frac{\Delta_n}{\delta_n}}\times \frac{\Delta_n}{\delta_n}\\
K =& 11\times\frac{(1-D)\sigma_{max,0}}{\delta_n}\times e^{1-\frac{\Delta_n}{\delta_n}}\times (1-\frac{\Delta_n}{\delta_n})\\
\end{array}
\right.
\quad \text{if} \quad kflag=2
\end{equation}
\begin{equation} %kflag=3
\left \{
\begin{array}{rl}
T =& T_{max}+K\times(\Delta_n-\Delta_{max})\\
K =& \frac{(1-D)\sigma_{max,0}*e}{\delta_n}\\
\end{array}
\right.
\quad \text{if} \quad kflag=3
\end{equation}
Right now the equations look like this
Here's an option using a multitude of nested structures - equation for the numbering, aligned for the horizontal alignment of structures and dcases (or cases) for the left-braced content.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\newcommand{\Ddn}{\frac{\Delta_n}{\delta_n}}
\newcommand{\smz}{\sigma_{\mathrm{max}, 0}}
\begin{equation}
\begin{aligned}
&\begin{dcases}
\phantom{K}\mathllap{T} = (1 - D) \smz \times e^{1 - \Ddn} \times \Ddn \\
K = \frac{(1 - D) \smz}{\delta_n} \times e^{1 - \Ddn} \times \bigl( 1 - \Ddn \bigr)
\end{dcases} & \text{if $k$-flag} = 0 \\ % k-flag = 0
&\begin{dcases}
\phantom{K}\mathllap{T} = \alpha \smz \times e^{1 - \Ddn} \times \Ddn \\
K = \frac{\alpha \smz}{\delta_n} \times e^{1 - \Ddn} \times \bigl( 1 - \Ddn \bigr)
\end{dcases} & \text{if $k$-flag} = 1 \\ % k-flag = 1
&\begin{dcases}
\phantom{K}\mathllap{T} = \begin{aligned}[t]
&(1 - D) \smz \times e^{1 - \Ddn} \times \Ddn + T_{\mathrm{max}} \\
&{} - (1 - D) \smz \times e \times \frac{\Delta_{\mathrm{max}}}{\delta_n} \\
&{} + 10 \times \smz \times e^{1 - \Ddn} \times \Ddn
\end{aligned} \\
K = 11 \times \frac{(1 - D) \smz}{\delta_n} \times e^{1 - \Ddn} \times \bigl( 1 - \Ddn \bigr)
\end{dcases} & \text{if $k$-flag} = 2 \\ % k-flag = 2
&\begin{dcases}
\phantom{K}\mathllap{T} = T_{\mathrm{max}} + K \times (\Delta_n - \Delta_{\mathrm{max}}) \\
K = \frac{(1 - D) \smz \times e}{\delta_n}
\end{dcases} & \text{if $k$-flag} = 3
\end{aligned}
\end{equation}
\end{document}
How to use Latex to create a notation style like this image. or any other suggestions ?
\documentclass{article}
% See http://tex.stackexchange.com/questions/112576/math-mode-in-tabular-without-having-to-use-everywhere
\usepackage{amstext}
\usepackage{array}
\usepackage{amssymb}
\newcolumntype{L}{>{$}l<{$}}
\begin{document}
\textbf{Typing rules for F$_1$}
\begin{tabular}{LLL}
\hline
\text{\footnotesize(Env $\varnothing$)} &
\text{\footnotesize(Env $x$)}\\
\frac{}{\varnothing \vdash \diamond} &
\frac{E \vdash A \quad x \notin dom(E)}{E, x:A \vdash \diamond} \\
&&\\
\text{\footnotesize(Type Const} &
\text{\footnotesize(Type Arrow)}\\
\frac{E \vdash \diamond}{E \vdash K} &
\frac{E \vdash A \quad E \vdash B}{E \vdash A \rightarrow B} \\
&&\\
\text{\footnotesize(Val $x$)} &
\text{\footnotesize(Val Fun)} &
\text{\footnotesize(Val Appl)} \\
\frac{E\vdash \diamond}{E \vdash x :E(x)} &
\frac{E,x:A\vdash b:B}{E \vdash \lambda(x:A)b :A \rightarrow B} &
\frac{E \vdash b:A \rightarrow B \quad E \vdash a : A}{E \vdash b(a) : B} \\
\hline
\end{tabular}
\end{document}