How to write this mathematical formulas into latex - latex

I want to change this formula into Latex code:
the latex code generated by MathType is below:
\[\widetilde v(i) = \frac{{\sum\nolimits_{j \in {N_i}(D)} {w(i,j)v(j)} }}{{\sum\nolimits_{j \in {N_i}(D)} {w(i,j)} }}\]
but when i insert this code into vim-latex, somes errors happens, so that vim-latex cannot accept it:
mypaper.tex|559 error| LaTeX Error: Bad math environment delimiter.
mypaper.tex|559 error| Missing delimiter (. inserted). \endgroup \[\widetilde v(i) = \frac\left\{ \sum\nolimits_{j \in {N_i}(D)} {w(i,j...
mypaper.tex|559 error| Missing \right. inserted. \right . \[\widetilde v(i) = \frac\left\{ \sum\nolimits_{j \in {N_i}(D)} {w(i,j...
mypaper.tex|559 error| Extra }, or forgotten $. ...\nolimits_{j \in {N_i}(D)} {w(i,j)v(j)} } }\left\{ \sum\nolimits_{j ...
mypaper.tex|559 error| Extra }, or forgotten $. ...nolimits_{j \in {N_i}(D)} {w(i,j)v(j)} }} \left\{ \sum\nolimits_{j \...
mypaper.tex|559 error| Extra }, or forgotten \right. ...\sum\nolimits_{j \in {N_i}(D)} {w(i,j)} } }\] \right\}<++> \right\}<++>
mypaper.tex|559 error| Extra }, or forgotten \right. ...sum\nolimits_{j \in {N_i}(D)} {w(i,j)} }} \] \right\}<++> \right\}<++>
mypaper.tex|559 error| LaTeX Error: Bad math environment delimiter.
mypaper.tex|559 error| Extra \right. ...}(D)} {w(i,j)} }}\] \right\}<++> \right\} <++>
How to solve this problem ?

I use the follow code to solve this problem:
\widetilde v(i) = \frac{ \sum\nolimits_{j \in {N_i}(D)} {w(i,j)v(j)} }{ \sum\nolimits_{j \in {N_i}(D)} {w(i,j)}}

Surround your math code with $$ signs.
For example:
$$ sin^2(\theta) +cos^2(\theta) = 1 $$
will produce your desired equation.

\begin{document}
\begin{equation}
\tilde{v}(\it {i})=\frac{\Sigma_{j\epsilon N_iD}
W(\it{i,j})v(\it{j})}{{\Sigma_{j\epsilon N_iD} W(\it{i,j})}}
\end{equation}
\end{document}
This seem to work.

Related

Caption an equation paragraph

I am trying to include different equation paragraphs in my LaTex document. Is it somehow possible to visually separate the paragraphs (e.g. by horizontal lines) and give them different captions?
I don't want the captions to emerge in the table of content, just underneath the equations.
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\section{Mathematical Formulation}
\begin{equation}
\operatorname{Max} F=\sum_{u,v \in V \mid u<v} \left(d_{uv} + d_{vu}\right) x_{uv}
\end{equation}
such that:
\begin{equation}
\sum_{l \in L_{u v}} y_{l} \geq x_{u v} \hspace{4em} u, v \in V \mid u<v
\end{equation}
\begin{equation}
\sum_{l \in \tilde L_{i j}} y_{l} \geq 1 \hspace{5em} \ \lbrack i,j \rbrack \in E
\end{equation}
%Next paragraph here
\begin{equation}
\operatorname{Min} F=\sum_{u \in V} \sum_{l \in L} \sum_{(i, j) \in \vec {E_{l}}} t_{l i j} x_{u l i j}
\end{equation}
\begin{equation}
\sum_{l \in L} \sum_{(i, v) \in \vec{E}_{l}} x_{u l i v}-\sum_{l \in L} \sum_{(v, j) \in \vec{E}_{l}} x_{u l v j}=d_{u v} \hspace{4em} u,v \in V \mid u \ne v
\end{equation}
\end{document}
The caption should look similar to the one for my GAMS code:
You could create a custom command like this:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcounter{foo}
\newcommand{\mycaption}[1]{
{
\medskip
\centering
\setcounter{foo}{\theequation}
\addtocounter{foo}{1}
Equation \thefoo: #1
\vskip-0.5\baselineskip
\noindent\hrulefill
}
}
\begin{document}
\section{Mathematical Formulation}
\begin{equation}
\operatorname{Max} F=\sum_{u,v \in V \mid u<v} \left(d_{uv} + d_{vu}\right) x_{uv}
\end{equation}
such that:
\begin{equation}
\sum_{l \in L_{u v}} y_{l} \geq x_{u v} \hspace{4em} u, v \in V \mid u<v
\end{equation}
\begin{equation}
\sum_{l \in \tilde L_{i j}} y_{l} \geq 1 \hspace{5em} \ \lbrack i,j \rbrack \in E
\end{equation}
%Next paragraph here
\mycaption{some text}
\begin{equation}
\operatorname{Min} F=\sum_{u \in V} \sum_{l \in L} \sum_{(i, j) \in \vec {E_{l}}} t_{l i j} x_{u l i j}
\end{equation}
\begin{equation}
\sum_{l \in L} \sum_{(i, v) \in \vec{E}_{l}} x_{u l i v}-\sum_{l \in L} \sum_{(v, j) \in \vec{E}_{l}} x_{u l v j}=d_{u v} \hspace{4em} u,v \in V \mid u \ne v
\end{equation}
\end{document}
Or if you prefer a separate counter:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcounter{foo}
\newcommand{\mycaption}[1]{
{
\medskip
\centering
% \setcounter{foo}{\theequation}
\addtocounter{foo}{1}
Model \thefoo: #1
\vskip-0.5\baselineskip
\noindent\hrulefill
}
}
\begin{document}
\section{Mathematical Formulation}
\begin{equation}
\operatorname{Max} F=\sum_{u,v \in V \mid u<v} \left(d_{uv} + d_{vu}\right) x_{uv}
\end{equation}
such that:
\begin{equation}
\sum_{l \in L_{u v}} y_{l} \geq x_{u v} \hspace{4em} u, v \in V \mid u<v
\end{equation}
\begin{equation}
\sum_{l \in \tilde L_{i j}} y_{l} \geq 1 \hspace{5em} \ \lbrack i,j \rbrack \in E
\end{equation}
%Next paragraph here
\mycaption{some text}
\begin{equation*}
\operatorname{Min} F=\sum_{u \in V} \sum_{l \in L} \sum_{(i, j) \in \vec {E_{l}}} t_{l i j} x_{u l i j}
\end{equation*}
\begin{equation}
\sum_{l \in L} \sum_{(i, v) \in \vec{E}_{l}} x_{u l i v}-\sum_{l \in L} \sum_{(v, j) \in \vec{E}_{l}} x_{u l v j}=d_{u v} \hspace{4em} u,v \in V \mid u \ne v
\end{equation}
\end{document}

align ! missing } inserted

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}

LaTeX: Split and gathered environment

I would like to split on multiple lines an equation which contain tikzpicture in gathered environment. I have tried to use align and split environments but both did not work...
Here is a working example where the equation is on one line:
\documentclass[12pt]{article}
\usepackage{amssymb}
% !TEX program = lualatex
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{equation}
2\Im\left(F(q^2)\right) =
\begin{gathered}
\scalebox{0.7}{
\begin{tikzpicture}
\begin{feynman}
\vertex (i1) {\(s\)};
\vertex [right=of i1] (a);
\vertex [right=of a] (b);
\vertex [right=of b] (i2);
\diagram* {
i1 -- a --[half left] b -- i2,
b --[half left, double] a,
};
%% Find the midpoint which is halfway between a and b
\coordinate (midpoint) at ($(a)!0.5!(b)$);
%% Draw a line starting 2 units above the midpoint, and
%% ending 2 units below the midpoints
\draw [dashed] ($(midpoint) + (0, 0.8)$) -- ($(midpoint) + (0,-0.8)$);
\end{feynman}
\end{tikzpicture}
}
\end{gathered}
= \int\frac{\,d^d k}{i\pi^{d/2}} \left[2\pi i\: \theta(k^0)\delta(k^2-m^2)\right]\left[2\pi i\: \theta(q^0-k^0)\delta((q-k)^2)\right]%
\end{equation}
\end{document}
Here is what I would like to do
\documentclass[12pt]{article}
\usepackage{amssymb}
% !TEX program = lualatex
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{equation}
\begin{split}
2\Im\left(F(q^2)\right) &=
\begin{gathered}
\scalebox{0.7}{
\begin{tikzpicture}
\begin{feynman}
\vertex (i1) {\(s\)};
\vertex [right=of i1] (a);
\vertex [right=of a] (b);
\vertex [right=of b] (i2);
\diagram* {
i1 -- a --[half left] b -- i2,
b --[half left, double] a,
};
%% Find the midpoint which is halfway between a and b
\coordinate (midpoint) at ($(a)!0.5!(b)$);
%% Draw a line starting 2 units above the midpoint, and
%% ending 2 units below the midpoints
\draw [dashed] ($(midpoint) + (0, 0.8)$) -- ($(midpoint) + (0,-0.8)$);
\end{feynman}
\end{tikzpicture}
}
\end{gathered}\\
&= \int\frac{\,d^d k}{i\pi^{d/2}} \left[2\pi i\: \theta(k^0)\delta(k^2-m^2)\right]\left[2\pi i\: \theta(q^0-k^0)\delta((q-k)^2)\right]%
\end{split}
\end{equation}
\end{document}
The latter returns a error due to the gathered in the split environment.
Does any of you know to solution to my problem ?
It's unclear to me what your desired result should look like exactly, but I think this should be approximately what you want:
\documentclass[12pt]{article}
\usepackage{amssymb}
% !TEX program = lualatex
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{align}
2\Im\left(F(q^2)\right) &=
\parbox{0.5\linewidth}{%
\scalebox{0.7}{
\begin{tikzpicture}
\begin{feynman}
\vertex (i1) {\(s\)};
\vertex [right=of i1] (a);
\vertex [right=of a] (b);
\vertex [right=of b] (i2);
\diagram* {
i1 -- a --[half left] b -- i2,
b --[half left, double] a,
};
%% Find the midpoint which is halfway between a and b
\coordinate (midpoint) at ($(a)!0.5!(b)$);
%% Draw a line starting 2 units above the midpoint, and
%% ending 2 units below the midpoints
\draw [dashed] ($(midpoint) + (0, 0.8)$) -- ($(midpoint) + (0,-0.8)$);
\end{feynman}
\end{tikzpicture}
}
} \\
&= \int\frac{\,d^d k}{i\pi^{d/2}} \left[2\pi i\: \theta(k^0)\delta(k^2-m^2)\right]\left[2\pi i\: \theta(q^0-k^0)\delta((q-k)^2)\right] \notag
\end{align}
\end{document}
This gives the following result:

How can I align equations belong to different { part? [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 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 can I customize the spaces between consecutive equations on latex?

I am working on my thesis (a report type file) in which I have several consecutive equations associated to some mathematical model, the thing is that those are too separate to each other and looks not pretty good, so I would like to know how can customize this. I am using a report type file and I have been around though to many pages without finding a good answer to this.
The code is the following:
\begin{equation}
\sum_{k \in K} \sum_{i \in V_{1}}v_{ijkg} \leq d_{jg} \hspace*{0.3 cm} \forall j \in V_{2}, \hspace{0.1 cm} \forall g \in G
\end{equation}
\begin{equation}
\sum_{i \in V_{1}}\sum_{j \in V_{2}} \sum_{g \in G} v_{ijkg} \leq Q_{k} \hspace*{0.3 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{j \in V_{2}} \sum_{k \in K} v_{ijkg} \leq W_{ig}, \hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall g \in G
\end{equation}
\begin{equation}
d_{jg}y_{jk} \geq v_{ijkg}, \hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall j \in V_{2}, \hspace*{0.1 cm} \forall k \in K, \hspace*{0.1 cm} \forall g \in G
\end{equation}
\begin{equation}
v_{ijkg} \leq Q_{k} \ast z_{i}, \hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall j \in V_{2}, \hspace*{0.1 cm} \forall k \in K, \hspace*{0.1 cm} \forall g \in G
\end{equation}
\begin{equation}
v_{ijkg} \leq Q_{k} \ast F_{ik}, \hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall j \in V_{2}, \hspace*{0.1 cm} \forall k \in K, \hspace*{0.1 cm} \forall g \in G
\end{equation}
\begin{equation}
\sum_{g \in G}v_{ijkg} \leq M \ast \sum_{s \in V} x_{sjk}, \hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall j \in V_{2}, \hspace*{0.1 cm} k \in K
\end{equation}
\begin{equation}
\sum_{s \in V,s \neq h} x_{shk} - \sum_{s \in V,s \neq h} x_{hsk}=0,\hspace*{0.3 cm} \forall h \in V, \hspace{0.1 cm} \forall k \in K
\end{equation}
\begin{equation}
u_{jkg}-u_{lkg}+Q_{k}x_{jlk} \leq Q_{k}-\sum_{i \in V_{1}}v_{ijkg}, \hspace*{0.3 cm} \forall j,l \in V_{2},j \neq l, \hspace*{0.1 cm} \forall g \in G, \hspace*{0.1 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{j \in V_{2}}x_{ijk} + \sum_{j \in V_{2}} x_{jik} \leq 2,\hspace*{0.3 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{i \in V_{1}} \sum_{j \in V_{2}} x_{ijk} \leq 1, \hspace*{0.3 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{s \in V,s \neq j}x_{sjk}=y_{jk}, \hspace*{0.3 cm} \forall j \in V_{2}, \hspace*{0.1 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{k \in K}F_{ik} \leq I \ast z_{i}, \hspace*{0.3 cm} \forall i \in V_{1}
\end{equation}
\begin{equation}
\sum_{j \in V_{2}} x_{ijk} = F_{ik}, \hspace*{0.3 cm} \forall i \in V_{1} \hspace*{0.1 cm} \forall k \in K
\end{equation}
\begin{equation}
\sum_{s \in V} \sum_{p \in V} T^{c}_{sp} x_{spk} \leq SRT, \hspace*{0.3 cm} \forall k \in K_{1}
\end{equation}
\begin{equation}
\sum_{s \in V} \sum_{p \in V} T^{h}_{sp} x_{spk} \leq SRT, \hspace*{0.3 cm} \forall k \in K_{2}
\end{equation}
\begin{equation}
\begin{split}
x_{spk} \in \{0,1\} \hspace*{0.1 cm} \forall s,p \in V,s \neq p, & \hspace*{0.1 cm} \forall k \in K \hspace*{0.2 cm} \\ y_{ik} \in \{0,1\}, \hspace*{0.1 cm} i \in V_{1} \hspace*{0.1 cm} \forall k \in K & \\ v_{ijkg} \in \mathbb{Z}^{+0}, \hspace*{0.1 cm} \forall i \in V_{1}, \hspace*{0.1 cm} \forall j \in V_{2}, \hspace*{0.1 cm} \forall & k \in K, \hspace*{0.1 cm} \forall g \in G \\ z_{i} \in \{0,1\}, \hspace*{0.1 cm} \forall i \in V_{1}& \\ F_{ik} \in \{0,1\}, \hspace*{0.1 cm} i \in V_{1} \hspace*{0.1 cm} \forall & ,k \in K \\ u_{jkg} \in \mathbb{Z}^{+}, \hspace*{0.1 cm} j \in V_{2} \hspace*{0.1 cm} \forall k \in & K, \hspace*{0.1 cm} \forall g \in G
\end{split}
\end{equation}
Here is a picture of some part of the output. The equations list take two entirely sheets.
any ideas? thanks in advance.
You could temporarily reduce the space above/below of the equations:
{
\addtolength{\belowdisplayskip}{-0.5ex}
\addtolength{\belowdisplayshortskip}{-0.5ex}
\addtolength{\abovedisplayskip}{-0.5ex}
\addtolength{\abovedisplayshortskip}{-0.5ex}
\begin{equation}
....
\end{equation}
\begin{equation}
....
\end{equation}
}

Resources