How to make a diagram in Latex? - latex

I would like to make this diagram in latex but I don't know even how to start:

As said in the comments, the tikz package is great to do this (and about any) kind of diagram.
The following example should give you something to start with.
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\node (left) at ( 0,0) {\(\overbracket[.4pt]{\underbracket[.4pt]{\Delta\Pi} \text{ and } \Delta\mu}\)};
\node (right) at (10,0) {\(\Delta G \text{ and } \Delta T\)};
\draw [-{>[scale=1.5]}] (right.north) to [out=150, in=30] (left.north);
\draw [-{>[scale=1.5]}] (-.7,-.29) to [out=-30, in=-150] (right.south);
\end{tikzpicture}
\end{document}

Related

Nesting blochspheres in tikzpictures using the blochsphere package

I am using the blochsphere package (see 1) and I want to nest it in another tikzpicture, to work with several blochspheres. The manual tells one to put "nested=true" in the settings for \begin{tikzpicture}. Unfortunately there are many errors, even when using the blochsphere example, given in the manual - which I use to provide a MWE:
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw (0,0) node []{
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
}
\end{tikzpicture}
\end{figure}
\end{document}
The code above is the MWE. The following code gives the example from the manual (that works, but is not nested):
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
\end{figure}
\end{document}
One error e.g. is the following (but there are a lot):
! Undefined control sequence.\tmp ->\endgroup \draw[current plane,on layer=back,opacity=0.3] (\agamma -\... \drawBallGrid[style={opacity=0.3}]{30}{30}
In the case of my personal blochsphere I get those as well as other errors like missing number treated as zero etc.
Could someone help me make the blochsphere package work to nest in another tikzpicture?
Thank you!
The ; at the end of the path is missing.
That being said, nesting tikz pictures in nodes is usually not a good idea - surprising things can happen...
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{blochsphere}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw (0,0) node []{
\begin{blochsphere}[nested=false,radius=1.5 cm,tilt=15,rotation=-20]
\drawBallGrid[style={opacity=0.3}]{30}{30}
\drawGreatCircle[style={dashed}]{-60}{0}{0}
\drawGreatCircle[style={dashed}]{60}{0}{0}
\drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
\drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}
\node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
\node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};
\labelLatLon{up}{90}{0};
\labelLatLon{down}{-90}{90};
\node[above] at (up) {{\tiny $\left|1\right>$ }};
\node[below] at (down) {{\tiny $\left|0\right>$}};
\labelLatLon[labelmark=false]{d}{15}{90};
\node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\labelLatLon[labelmark=false]{d2}{5}{78};
\end{blochsphere}
};
\end{tikzpicture}
\end{figure}
\end{document}
The nested=false option is for when you use the blochsphere environment directly in a tikzpicture, e.g.
\begin{tikzpicture}
\begin{blochsphere}[nested=true]
\drawBall
\end{blochsphere}
\end{tikzpicture}
because it will switch off the tikzpicture which is normally automatically added to the blochsphere environment (... I think there is some problem with expansion going on if used like this, not everything is drawn...).
The easy way out would be to ditch your tikz picture and place everything you wanted to draw in your tikz picture inside the blochsphere environment.

How to avoid tiltled lines in circuitikz?

I want the line on the left to end right at the y-coordinate of the SPDT input so I can connect them seamlessly with a straight line. As you can see, the line on the left ends a bit lower than the SPDT input which causes the connecting line to be tilted
Is there a way to automatically adjust the length? I'd rather avoid inching towards an acceptable result by adjusting the length over and over again manually.
Here is the code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\begin{document}
\begin{figure}
\begin{circuitikz}
\node [spdt, rotate=90] (S) {};
\draw
(S.in) to [C] ++(0,-2)
to ++(-2,0)
to [V] ++(0,3)
to(S.out 1);
\end{circuitikz}
\end{figure}
\end{document}
Instead of adjusting the length on the left, I would just make sure that it is above the switch and then use -| to connect it with first an horizontal segment and then a vertical segment:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\begin{document}
\begin{figure}
\begin{circuitikz}
\node [spdt, rotate=90] (S) {};
\draw
(S.in) to [C] ++(0,-2)
to ++(-2,0)
to [V] ++(0,3.5)
-| (S.out 1)
;
\end{circuitikz}
\end{figure}
\end{document}

Tikz-Network Draw Edge without Node (Invisible Node) Latex

I want to draw an edge from a point below a node, to the node. Here is what I have so far:
\begin{tikzpicture}
\Vertex[x=0,label=1, size=1.2]{A} \Vertex[x=3,size=1.2,label=2]{B} \Vertex[x=6,size=1.2,label=3]{C}
\Edge[Direct,label=0.4,bend=20,fontscale=1.2](A)(B)
\Edge[Direct,label=0.6,bend=30](A)(C)
\Edge[Direct,label=0.25,bend=20](C)(B)
\end{tikzpicture}
Which yields:
I want to draw an arrow from about 3mm below node 1 directed to node 1
\documentclass{article}
\usepackage{tikz-network}
\begin{document}
\begin{tikzpicture}
\Vertex[x=0,label=1, size=1.2]{A} \Vertex[x=3,size=1.2,label=2]{B} \Vertex[x=6,size=1.2,label=3]{C}
\Edge[Direct,label=0.4,bend=20,fontscale=1.2](A)(B)
\Edge[Direct,label=0.6,bend=30](A)(C)
\Edge[Direct,label=0.25,bend=20](C)(B)
\end{tikzpicture}
\end{document}
With the positioning library of tikz, you could create a dummy node below A at whatever distance you like and then draw the edge from this dummy node to A
\documentclass{article}
\usepackage{tikz-network}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\Vertex[x=0,label=1, size=1.2]{A}
\Vertex[x=3,size=1.2,label=2]{B}
\Vertex[x=6,size=1.2,label=3]{C}
\node[below=1.5cm of A] (D) {};
\Edge[Direct,label=0.4,bend=20,fontscale=1.2](A)(B)
\Edge[Direct,label=0.6,bend=30](A)(C)
\Edge[Direct,label=0.25,bend=20](C)(B)
\Edge[Direct,label=0.25](D)(A)
\end{tikzpicture}
\end{document}

How to change arrow tip in tikz

Is there a simple way to increase the size of an arrow tip using something like:
\tikzset{myptr/.style=->, ????}
without designing a new arrow style from scratch?
One solution, very quick, to just scale the arrow head is number %2 in the following:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}
%1
\draw [->,>=stealth] (0,.5) -- (2,.5);
%2
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=3,>=stealth]{>}}},postaction={decorate}] (0,0) -- (2,0);
\end{tikzpicture}
\end{document}
This produces:
(sorry for excessive zoom).
Much more in the answers to this question and in this answer, that I used as a source.
Addendum
\tikzset approach. This code:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}
\tikzset{myptr/.style={decoration={markings,mark=at position 1 with %
{\arrow[scale=3,>=stealth]{>}}},postaction={decorate}}}
%1
\draw [->,>=stealth] (0,.5) -- (2,.5);
%2
\draw [myptr] (0,0) -- (2,0);
\end{tikzpicture}
\end{document}
produces the same output as the above one (source: PGF Manual, section 2.8).
Obviously you can use -Latex instead of stealth.
There is a new solution, see https://latexdraw.com/exploring-tikz-arrows/#t-1610685307397. It allows changing both the length and width of arrows:
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows}
\begin{document}
\begin{tikzpicture}
\draw [-{Stealth[length=3mm, width=2mm]}] (0,0.5) -- (1,0.5);
\draw [-stealth] (0,0) -- (1,0);
\end{tikzpicture}
\end{document}

Positioning of hyperlinked shapes with matrix in tikz

I can draw a hyperlinked shape in tikz using the following code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{hyperref}
\begin{document}
\begin{tikzpicture}
\node {%
\href{http://www.stackoverflow.com}{%
\begin{tikzpicture}
\filldraw[blue] circle(1cm) node [white] {Click};
\end{tikzpicture}}};
\end{tikzpicture}
\end{document}
Now I would like to organize my shapes using the matrix, and have one of the shapes hyperlinked. It almost works, but I am not able to align the hyperlinked shape with the rest of the shapes, and it is bigger than the other shapes:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{hyperref}
\begin{tikzpicture}
\matrix [matrix of nodes, row sep = 1cm, column sep=1cm, nodes={circle, draw}]
{% First row:
1 & 2 \\
% second row:
\path node {\href{http://www.stackoverflow.com}{%
\begin{tikzpicture}
\node {3};
\end{tikzpicture}}}; & 4\\
};
\end{tikzpicture}
\end{document}
I get the following result:
(source: picture.im)
My question is: How could I align shape 3 in the picture above with the other shapes, and get rid of the outer circle?
I think you're aiming too high and your second {tikzpicture} is messing up your layout.
What do you think about the code below? Is that what you've been looking for?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage[pdftex,active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usepackage{hyperref}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes, row sep = 1cm, column sep=1cm, nodes={circle, draw}]
{%
1 & 2\\%
\href{http://stackoverflow.com}{3} & 4\\%
};
\end{tikzpicture}
\end{document}
BTW: the \PreviewEnvironment{tikzpicture} is not really needed, but it makes for a nice, cropped pdf...

Resources