Positioning of hyperlinked shapes with matrix in tikz - latex

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...

Related

How to make a graphic where one image points to two other images with arrows in latex?

I want to create a graphic like the one in the attached image in latex, where each box represents an image (a graphic I want to insert). I also want to be able to write a word over the arrows that point from one image to another.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[>=latex,node distance=2em]
\node(a){\includegraphics[width=4cm]{example-image-a}};
\node[right=of a](b){\includegraphics[width=4cm]{example-image-b}};
\draw[->] (a) -- (b);
\end{tikzpicture}
\caption{Two graphics.}
\end{figure}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[>=latex,node distance=2em]
\node(a){\includegraphics[width=3cm]{example-image-a}};
\matrix[right=of a,row sep=2em] {
\node(b){\includegraphics[width=3cm]{example-image-b}};\\
\node(c){\includegraphics[width=3cm]{example-image-duck}};\\
};
\draw[->] (a) -- (b);
\draw[->] (a) -- (c);
\end{tikzpicture}
\caption{Three graphics.}
\end{figure}
\end{document}
visit: https://tex.stackexchange.com/questions/527216/diagrams-arrows

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}

How to make a diagram in 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}

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}

Latex: Space remove between parboxes

I try to remove the vertical space between the textboxes. However, since I use the newcommand that opens a new tikzpicture each time, I cannot use setspace I think?
Any other ideas?
\documentclass[10pt,a5paper]{article}
\usepackage[left=10mm, right=10mm, bottom=15mm, top=10mm, footskip=5mm]{geometry}
\usepackage{xcolor}
\xdefinecolor{links}{RGB}{251,212,180}
\xdefinecolor{rechts}{RGB}{214,227,188}
\xdefinecolor{mitte}{RGB}{218,216,215}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{shapes}
\tikzstyle{sms} = [rectangle callout, draw,very thick, rounded corners, minimum height=20pt]
\newcommand{\smsr}[1]{\begin{flushright}
\begin{tikzpicture}
\node [sms, align=right,callout relative pointer={(0.5,0)}, fill=rechts] {\begin{varwidth}{0.7\textwidth}{#1}\end{varwidth}};
\end{tikzpicture}\end{flushright}}
\newcommand{\smsl}[1]{\begin{flushleft}
\begin{tikzpicture}
\node[sms, align=left,callout relative pointer={(-0.5,0)}, fill=links] {\begin{varwidth}{0.7\textwidth}{#1}\end{varwidth}};
\end{tikzpicture}\end{flushleft} }
\newcommand{\datum}[1]{\begin{center} \begin{tikzpicture}
\node[rectangle, very thick, text width=0.4\textwidth, rounded corners, draw,align=center, fill=mitte] {#1};
\end{tikzpicture} \end{center}}
\begin{document}
\small
\datum{Saturday, 22.July}
\smsl{Send Hallo}
\smsr{Answer Bye. Very long line to show the function of automatic line-breaking.}
\smsr{Still awake?}
\end{document}
Inserting each tikzpicture inside another environment may insert unwanted vertical spacing. Perhaps don't use them:
\documentclass[10pt,a5paper]{article}
\usepackage[left=10mm, right=10mm, bottom=15mm, top=10mm, footskip=5mm]{geometry}
\usepackage{xcolor}
\xdefinecolor{links}{RGB}{251,212,180}
\xdefinecolor{rechts}{RGB}{214,227,188}
\xdefinecolor{mitte}{RGB}{218,216,215}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{shapes}
\tikzstyle{sms} = [rectangle callout, draw,very thick, rounded corners, minimum height=20pt]
\newcommand{\smsr}[1]{\hfill
\begin{tikzpicture}
\node [sms, align=right,callout relative pointer={(0.5,0)}, fill=rechts] {\begin{varwidth}{0.7\textwidth}{#1}\end{varwidth}};
\end{tikzpicture}
\par}
\newcommand{\smsl}[1]{%
\begin{tikzpicture}
\node[sms, align=left,callout relative pointer={(-0.5,0)}, fill=links] {\begin{varwidth}{0.7\textwidth}{#1}\end{varwidth}};
\end{tikzpicture}
\par}
\newcommand{\datum}[1]{%
\begin{center}
\begin{tikzpicture}
\node[rectangle, very thick, text width=0.4\textwidth, rounded corners, draw,align=center, fill=mitte] {#1};
\end{tikzpicture}
\end{center}}
\setlength{\parindent}{0pt}
\begin{document}
\small
\datum{Saturday, 22 July}
\smsl{Send Hallo}
\smsr{Answer Bye. Very long line to show the function of automatic line-breaking.}
\smsr{Still awake?}
\end{document}
I also removed any paragraph indent, but kept the title set with some distance between the following text bubbles (using center).
An alternative to the above, if you plan on using \smsl, \smsr and \datum for everything, would be to use \raggedright, \raggedleft and \centering respectively (rather than \hfill for \smsl and center for datum).

Resources