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:
Related
I would like to add an arrow from Variable 5 to the middle of the arrow that connects Variable 2 and Variable 3.
\documentclass[jou]{apa7}
\usepackage[american]{babel}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,text width=1.90cm,align=center}
}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[mynode] (v1){Variable 1};
\node[mynode,below left=of v1](v2) {Variable 2};
\node[mynode,below right=of v1](v3) {Variable 3};
\node[mynode,below = 2.5cm of v1] (v4){Variable 4};
\node[mynode, above right=of v1](v5) {Variable 5};
\draw[-latex] (v2.north) -- node[auto,] {a} (v1.west);
\draw[-latex] (v1.east) -- node[auto,] {b} (v3.north);
\draw[-latex] (v2.east) -- node[below, align=center] {c} (v3.west);
\draw[-latex] (v2.south) -- node[below=3mm, align=center] {d} (v4.west);
\draw[-latex] (v3.south) -- node[below=3mm, align=center] {e} (v4.east);
\draw[-latex] (v5.south) -- node[auto,]{f} (v3.north);
\end{tikzpicture}
\end{figure}
\end{document}
You can use the calc library to calculate the middle between the nodes v2 and v3:
\documentclass[jou]{apa7}
\usepackage[american]{babel}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\tikzset{mynode/.style={draw,text width=1.90cm,align=center}
}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\node[mynode] (v1){Variable 1};
\node[mynode,below left=of v1](v2) {Variable 2};
\node[mynode,below right=of v1](v3) {Variable 3};
\node[mynode,below = 2.5cm of v1] (v4){Variable 4};
\node[mynode, above right=of v1](v5) {Variable 5};
\draw[-latex] (v2.north) -- node[auto,] {a} (v1.west);
\draw[-latex] (v1.east) -- node[auto,] {b} (v3.north);
\draw[-latex] (v2.east) -- node[below, align=center] {c} (v3.west);
\draw[-latex] (v2.south) -- node[below=3mm, align=center] {d} (v4.west);
\draw[-latex] (v3.south) -- node[below=3mm, align=center] {e} (v4.east);
\draw[-latex] (v5.south) -- node[auto,]{f} (v3.north);
\draw[-latex] (v5.south) -- ($(v2)!.5!(v3)$);
\end{tikzpicture}
\end{figure}
\end{document}
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}
I would appreciate any tip on the following question.
For a j-period timeline, I like to depict a binary tree up to (including) period 2 (i.e. j = 0,1,2) and then dotted arrows to the final period.
\begin{figure} [H]
\tikzstyle{bag} = [text width=5em, text centered]
\tikzstyle{end} = []
\begin{tikzpicture}[sloped]
\node (a) at ( 0,0) [bag] {$\$ S_{0,0}$}; %[bag] {$ \$ A $}
\node (b) at ( 4,-2) [bag] {$S_{1,0}=S_0 d$}; %[bag] {B}
\node (c) at ( 4,2) [bag] {$S_{1,1}=S_0 u$}; %[bag] {C}
\node (d) at ( 8,-4) [bag] {$S_{2,0}=S_0 d^2$}; %[bag] {D}
\node (e) at ( 8,0) [bag] {$S_{2,1}=S_0 d u$}; %[bag] {E}
\node (f) at ( 8,4) [bag] {$S_{2,2}=S_0 u^2$}; %[bag] {F}
\draw [->] (a) to node [below] {$(1-p)$} (b);
\draw [->] (a) to node [above] {$p$} (c);
\draw [->] (c) to node [below] {$p^2$} (f);
\draw [->] (c) to node [above] {$(1-p)p$} (e);
\draw [->] (b) to node [below] {$(1-p)p$} (e);
\draw [->] (b) to node [above] {$(1-p)^2$} (d);
%Next, the timeline
%use a syntax similar to:
% \draw (0,0) node[below=110pt] {$ n=0 $} node[above=110pt] {$ bla... $};
%for timelines above and below the tree.
%In this case, only the timeline below the tree is used:
\draw (0,0) node[below=140pt] {$ j=0 $} node[above=140pt] {$ i=0 $};
\draw (4,0) node[below=140pt] {$ j=1 $} node[above=140pt] {$ i=0,1 $};
\draw (8,0) node[below=140pt] {$ j=2 $} node[above=140pt] {$ i=0,1,2 $} ;
\draw (10,0) node[below=140pt] {$ \cdots $} node[above=140pt] {$ \cdots $};
\draw (12,0) node[below=140pt] {$ j=T $} node[above=140pt] {$ i=0,1,\cdots,k $};
\end{tikzpicture}
\caption{A binomial tree %
\label{fig:multiperiodtree}}
\end{figure}
There are 2 problems with the output: 1) The formula label at node (2,2) and (2,1) are split into 2 lines, yet node (2,0) is retained on the same line. Why?
2) How to depict dotted arrows to the state where j=T (timeline axis at the bottom of the figure)?
I have made a social graph, as you can see below, but couldn't figure out a way to make the nodes inside two circles in which the nodes in the middle (F, D, K, M) are placed in the intersection of the two circles.
And is there a simple way to label left circle, right circle and the intersection?
Here is the code and thank you so much in advance:
\begin{tikzpicture}
\begin{scope}[every node/.style={circle,thick,draw}]
\node (A) at (0,0) {A};
\node (B) at (0,3) {B};
\node (C) at (2,3) {C};
\node (E) at (1,-1.5) {E};
\node (G) at (1,1.5) {G};
\node (F) at (5,2) {F} ;
\node (D) at (4,1) {D};
\node (K) at (5,0) {K};
\node (M) at (4,-1) {M};
\node (H) at (8.5,0) {H};
\node (I) at (9,2.5) {I};
\node (J) at (8,1.5) {J};
\node (N) at (7.5,-1.5) {N};
\node (L) at (7,3) {L} ;
\node (Q) at (9.5,1) {Q} ;
\end{scope}
\begin{scope}[>={Stealth[black]},
every node/.style={fill=white,circle},
every edge/.style={draw=red,very thick}]
\draw (A) -> (G);
\draw (B) -- (A);
\draw (B) -- (C);
\draw (B) -- (G);
\draw (E) -- (G);
\draw (E) -- (A);
\draw (G) -- (C);
\draw (L) -- (I);
\draw (H) -- (J);
\draw (Q) -- (H);
\draw (I) -- (J);
\draw (N) -- (H);
\draw (Q) -- (J);
\draw (A) -> (D);
\draw (E) -- (M);
\draw (E) -- (D);
\draw (G) -- (D);
\draw (G) -- (F);
\draw (C) -- (F);
\draw (C) -- (M);
\draw (N) -- (K);
\draw (N) -- (F);
\draw (N) -- (M);
\draw (L) -- (F);
\draw (J) -- (F);
\draw (H) -- (F);
\end{scope}
\end{tikzpicture}
UPDATE:
After I added these 2 lines:
\draw (2,0.7) circle (4cm);
\draw (7,0.7) circle (4cm);
I get this:
I am only left with coloring the intersection so below these 2 lines I added:
%\draw clip circle (4cm);
%\fill[gray] (2,0.7) circle (4cm);
Which did the job but one of the circles hides its nodes!!
Any suggestions??
I think this is what you're looking for:
\begin{tikzpicture}
\begin{scope}
\draw (2,0.7) circle (4cm);
\clip (7,0.7) circle (4cm);
\fill[gray] (2,0.7) circle (4cm);
\draw (7,0.7) circle (4cm);
\end{scope}
\node[below=4.5cm of circle1] {Circle 1};
\node[below=4.5cm of circle2] {Circle 2};
\node[below=4cm of circle1,xshift=2.5cm] {Intersection};
\begin{scope}[every node/.style={circle,thick,draw}]
\node (A) at (0,0) {A};
\node (B) at (0,3) {B};
\node (C) at (2,3) {C};
\node (E) at (1,-1.5) {E};
\node (G) at (1,1.5) {G};
\node (F) at (5,2) {F} ;
\node (D) at (4,1) {D};
\node (K) at (5,0) {K};
\node (M) at (4,-1) {M};
\node (H) at (8.5,0) {H};
\node (I) at (9,2.5) {I};
\node (J) at (8,1.5) {J};
\node (N) at (7.5,-1.5) {N};
\node (L) at (7,3) {L} ;
\node (Q) at (9.5,1) {Q} ;
\end{scope}
\begin{scope}[>={Stealth[black]},
every node/.style={fill=white,circle},
every edge/.style={draw=red,very thick}]
\draw (A) -> (G);
\draw (B) -- (A);
\draw (B) -- (C);
\draw (B) -- (G);
\draw (E) -- (G);
\draw (E) -- (A);
\draw (G) -- (C);
\draw (L) -- (I);
\draw (H) -- (J);
\draw (Q) -- (H);
\draw (I) -- (J);
\draw (N) -- (H);
\draw (Q) -- (J);
\draw (A) -> (D);
\draw (E) -- (M);
\draw (E) -- (D);
\draw (G) -- (D);
\draw (G) -- (F);
\draw (C) -- (F);
\draw (C) -- (M);
\draw (N) -- (K);
\draw (N) -- (F);
\draw (N) -- (M);
\draw (L) -- (F);
\draw (J) -- (F);
\draw (H) -- (F);
\end{scope}
\end{tikzpicture}
Without seeing how you added the clip and fill instructions, I can't really tell you what's wrong.
Can I use \path to draw a line that goes through 2 edges.
Consider:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzstyle{status} = [rectangle, draw=black, text centered, anchor=north, text=black, minimum width=2em, minimum height=2em, node distance=6ex and 7em, font=\bfseries]
\tikzstyle{line} = [draw,thick,-latex]
\tikzstyle{transition} = [font=\small]
\begin{document}
\begin{tikzpicture}
\node [status, fill=green] (T) {H};
\node [status, fill=red, right=4em of T] (A) {A};
\node [status, fill=gray, right=4em of A] (D) {D};
\path [line] (T) -- (A) node[transition,pos=0.5,above,align=left] {$\#A \geq 1$};
\path [line] (A) -- (D) node[transition,pos=0.5,above,align=left] {wait $\tau$ tick\\$\tau\sim\mathcal{G}(\lambda)$};
%\path [line] (D) -| (T) node[transition,pos=0.83,left] {$p_{repl}$};
\end{tikzpicture}
\end{document}
Screenshot:
Mockup of what I want:
Easier than we thought, you can make it substituting the commented line (line number 17) in your code with:
\path [line] (D) -- ++(0,-1) -- +(-4.25,0) -- (T) node[transition,pos=0.3,right] {$p_{repl}$};
The output:
Improvement: even better, using -| and then one aux point only instead of two (one is needed):
\path [line] (D) -- ++(0,-1) -| (T) node [transition,pos=0.8,left] {$p_{repl}$};