I want to center two tikzpictures which are both in a own subfloat on a landscape page. With my example code the begin of the second timeline is shifted. You can see the shift in the picture. I want to have the beginnigs of the two timelines on the same horizontal line.
\documentclass[a4paper,11pt,smallchapters,blue,extramargin,lnum]{article}
\usepackage{lscape}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{landscape}
\vspace*{\fill}
\begin{figure}[h]
\begin{center}
\subfloat[Situation 1 \label{fig:situationen-2.impl-exp3:situation1}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (10,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\newline
\subfloat[Situation 2 \label{fig:situationen-2.impl-exp3:situation2}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (5,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (10,0) node[below=3pt] {$ 100s $} node[above=12pt] {Senderate} node[above=1pt] {kleiner};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\caption{Untersuchte Situationen in Experiment 3 der 2.Implementierung} \label{fig:situationen-2.impl-exp2}
\end{center}
\end{figure}
\vspace*{\fill}
\end{landscape}
\end{document}
The problem is caused by the combination of centred text and the forced line break from \newline. You can avoid this by simply leaving an empty line to start a new paragraph:
\documentclass[a4paper,11pt,smallchapters,blue,extramargin,lnum]{article}
\usepackage{lscape}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{landscape}
\vspace*{\fill}
\begin{figure}[h]
\centering
% \begin{center}
\subfloat[Situation 1 \label{fig:situationen-2.impl-exp3:situation1}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (10,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\subfloat[Situation 2 \label{fig:situationen-2.impl-exp3:situation2}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (5,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (10,0) node[below=3pt] {$ 100s $} node[above=12pt] {Senderate} node[above=1pt] {kleiner};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\caption{Untersuchte Situationen in Experiment 3 der 2.Implementierung} \label{fig:situationen-2.impl-exp2}
% \end{center}
\end{figure}
\vspace*{\fill}
\end{landscape}
\end{document}
(I'm using \centering instead of the center environment to avoid additional vertical spacing, but for your use case that's not really important)
Related
I am trying to replicate some diagrams that I made using Microsoft Visio, using the tikz package in LaTeX. The basic diagrams are relatively easy to build, but when it comes to add more than two nodes next to each other, it gets quite tricky... I can't seem to find any documentation that justifies my needs to center and align the nodes like I've done in Visio.
These are the MS Visio diagrams:
But this is what I have got right now, using Tikz:
Here is a minimal reproducible example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{svg}
\usepackage{amsmath}
\usetikzlibrary{shapes.geometric, arrows, chains}
%%
%%TikZ Settings
\tikzstyle{main} = [rectangle, minimum width=3cm, minimum height=0.6cm,text centered, text width=3cm, draw=black, fill=black!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
%The "Remediação" diagram
\begin{tikzpicture}[node distance=1.5cm]
\node (principal) [main] {Remediação};
\coordinate[below of=principal] (a);
\begin{scope}[start chain=going right]
\node (rem-vuln-c-patch) [main, on chain, below of=principal, left of=a] {Remediação de Vulnerabilidade Normal com \textit{patch}};
\node (rem-vuln-c-c-patch) [main, on chain] {Remediação de Vulnerabilidade Crítica com \textit{patch}};
\node (rem-vuln-config) [main, on chain] {Remediação de Vulnerabilidade por má configuração};
\node (gest-vuln-s-patch) [main, on chain] {Gestão de Vulnerabilidade sem \textit{patch}};
\end{scope}
\node(gest-risco) [main, align=center, below of=rem-vuln-c-c-patch] {Gestão de Risco};
\draw [arrow] (principal) -| (rem-vuln-c-patch);
\draw [arrow] (principal) -| (rem-vuln-c-c-patch);
\draw [arrow] (principal) -| (rem-vuln-config);
\draw [arrow] (principal) -| (gest-vuln-s-patch);
\draw [arrow] (gest-vuln-s-patch) |- (gest-risco);
\draw [arrow] (gest-risco) -| (rem-vuln-c-patch);
\draw [arrow] (gest-risco) -- (rem-vuln-c-c-patch);
\end{tikzpicture}
% The "Balanço" diagram
\begin{tikzpicture}[node distance=1.5cm]
\node (principal) [main] {Balanço};
\coordinate[below of=principal] (a);
\begin{scope}[start chain=going right]
\node (lic-apr) [main, on chain, below of=principal, left of=a] {Lições aprendidas};
\node (reu-retro) [main, on chain] {Reunião de Retrospetiva};
\node (cri-rel-exec) [main, on chain] {Criação do relatório executivo};
\end{scope}
\draw [arrow] (principal) -| (lic-apr);
\draw [arrow] (principal) -| (reu-retro);
\draw [arrow] (principal) -| (cri-rel-exec);
\end{tikzpicture}
\end{document}
Using a tree might be easier than a chain:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{svg}
\usepackage{amsmath}
\usetikzlibrary{shapes.geometric, arrows, chains,positioning}
%%
%%TikZ Settings
\tikzstyle{main} = [rectangle, minimum width=3cm, minimum height=2cm,text centered, text width=3cm, draw=black, fill=black!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
%The "Remediação" diagram
\begin{tikzpicture}[
level distance=3cm,
sibling distance=4cm,
edge from parent path={[thick,->](\tikzparentnode.south) -- ++(0,-1cm) -| (\tikzchildnode.north)}
]
\node[main,minimum height=0.6cm] (principal) {Remediação}
child { node[main] (rem-vuln-c-c-patch) {Remediação de Vulnerabilidade Crítica com \textit{patch}} }
child { node[main] (rem-vuln-c-patch) {Remediação de Vulnerabilidade Normal com \textit{patch}} }
child { node[main] (rem-vuln-config) {Remediação de Vulnerabilidade por má configuração} }
child { node[main] (gest-vuln-s-patch) {Gestão de Vulnerabilidade sem \textit{patch}} };
\node(gest-risco) [main, align=center, below=4.5cm of principal,minimum height=0.6cm] {Gestão de Risco};
\draw[->,thick] (gest-risco) -| (rem-vuln-c-c-patch);
\draw[->,thick] (gest-risco) -| (gest-vuln-s-patch);
\draw[->,thick] ([xshift=-1.0cm]gest-risco.north) -| ([xshift=1.8cm]rem-vuln-c-patch);
\end{tikzpicture}
\end{document}
I am trying to draw an arrow to link these two pictures and demonstrate the rotation. Can I do this with this minipage idea or do I need to draw them differently?
\begin{minipage}{0,5\textwidth}
\begin{center}
\begin{tikzpicture}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {4}
-- cycle (108:\R) node[above] {5}
-- cycle (180:\R) node[below] {1}
-- cycle (252:\R) node[below] {2} -- cycle (324:\R) node[right] {3};
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}{0,5\textwidth}
\begin{center}
\begin{tikzpicture}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {3}
-- cycle (108:\R) node[above] {4}
-- cycle (180:\R) node[below] {5}
-- cycle (252:\R) node[below] {1} -- cycle (324:\R) node[right] {2};
\end{tikzpicture}
\end{center}
\end{minipage}
In theory you could use the tikzmark library to draw arrows between your two minipages, but I think it is easier to just put both drawing in a single tikzpicture:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{scope}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {4}
-- cycle (108:\R) node[above] {5}
-- cycle (180:\R) node[below] {1}
-- cycle (252:\R) node[below] {2} -- cycle (324:\R) node[right] {3};
\end{scope}
\begin{scope}[xshift=6cm]
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {3}
-- cycle (108:\R) node[above] {4}
-- cycle (180:\R) node[below] {5}
-- cycle (252:\R) node[below] {1} -- cycle (324:\R) node[right] {2};
\end{scope}
\draw[red,<->] (2.3,0) -- (3.8,0);
\end{tikzpicture}
\end{center}
\end{document}
I am trying to draw the number line but the more I add variables the more the numbers FADE AWAY and some are even DISAPPEARING COMPLETELY. Below is the code I have used, and the results are as shown in the image below. Anyone who can see the problem in this code?Thanks.
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,time/.style={minimum height=5mm,minimum width=6mm,fill=#1,text=black}]
\def\0{0}
\def\1{1}
\def\2{2}
\def\3{3}
\def\4{4}
\def\5{5}
\def\6{6}
\def\7{7}
\def\8{8}
\def\9{9}
\def\n{10}
\draw[black,-latex] (0,0)--(11,0);
\draw[black] (0,.2)--(0,-.2)
(\0,.2) node[above=2mm,time=white]{$ 2X$}
(\0,-.2) node[below=2mm,time=white]{$0$}
(\1,.2) node[above=2mm,time=white] (x) {$ $}--
(\1,-.2) node[below=2mm,time=white]{$ 1$}
(\2,.2) node[above=2mm,time=white] (x) {$ $}--
(\2,-.2) node[below=2mm,time=white]{$2 $}
(\3,.2) node[above=2mm,time=white] (x) {$ $}--
(\3,-.2) node[below=2mm,time=white]{$ 3 $}
(\4,.2) node[above=2mm,time=white] (x) {$ $}--
(\4,-.2) node[below=2mm,time=white]{$4 $}
(\5,.2) node[above=2mm,time=white] (x) {$ $}--
(\5,-.2) node[below=2mm,time=white]{$5 $}
(\6,.2) node[above=2mm,time=white] (x) {$ $}--
(\6,-.2) node[below=2mm,time=white]{$6 $}
(\7,.2) node[above=2mm,time=white] (x) { $ $}--
(\7,-.2) node[below=2mm,time=white]{$7 $}
(\8,.2) node[above=2mm,time=white] (x) {$ $}--
(\8,-.2) node[below=2mm,time=white]{$8 $}
(\9,.2) node[above=2mm,time=white] (x) {$2X(1-\frac{0.12}{12})^{-4\times12}(1+\frac{0.10}{2})^{5\times2} $}--
(\9,-.2) node[below=2mm,time=white]{$9 $}
(\n,.2) node[above=2mm,time=white] (x) {$ $}--
(\n,-.2) node[below=2mm,time=white]{$10 $};
\draw[->] (0.2,0.7)--(3.98,0.7);
\draw[->] (4.1,0.7)--(6.5,0.7);
\end{tikzpicture}
\end{document}
Use foreach to save code:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,
time/.style={minimum height=5mm,minimum width=6mm,fill=#1,text=black},
%every node/.style={draw},
]
\draw[black,-latex] (0,0)--(11,0);
\def\dx{1}
\foreach \i in {0,...,10} {
\ifnum\i>0
\def\ann{$ $}
\else
\def\ann{$ 2X$}
\fi
\draw[] (\i*\dx,.2) -- (\i*\dx,-.2)
node[pos=0,above=2mm,time=white] (P\i) {\ann}
node[pos=1,below=2mm,time=white] (Q\i) {$\i$};
}
\node[time=white] at (P9) (x) {$2X(1-\frac{0.12}{12})^{-4\times12}(1+\frac{0.10}{2})^{5\times2} $};
\draw[-latex] (P0)--(P4.center);
\draw[-latex] ([xshift=1mm]P4.center)--(P6.east);
\end{tikzpicture}
\end{document}
My code
\documentclass[11pt,twoside]{report}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw
(0,0)
to[sV, v<=$V$] ++(0,2.5)
to[R, l=$R$,i=$i$,-o] ++(3.5,0)
to[open, v^=$~~U$] ++(0,-2.5)
to[short,-o] ++(0,0)
--(0,0)
;
\end{circuitikz}
\end{document}
Gives me
I want
How do I remove polarity signs from the voltage source?
\documentclass{standalone}
\usepackage[
american,
]{circuitikz}
\begin{document}
\begin{circuitikz}[]
\draw
(0,0)
to[sV, voltage/american plus/.initial={}, voltage/american minus/.initial={}, v<=$V$] ++(0,2.5)
to[R, l=$R$,i=$i$,-o] ++(3.5,0)
to[open, v^=$~~U$] ++(0,-2.5)
to[short,-o] ++(0,0)
--(0,0)
;
\end{circuitikz}
\end{document}
I had tried this code and I want the braces in the figure as there are in the attached picture.
\begin{figure}[hbt!]
\begin{center}
\begin{tikzpicture}[
thick,
acteur/.style={
circle,
fill=black,
thick,
inner sep=2pt,
minimum size=0.2cm
}
]
\node (a1) at (-0.3,0.65) [acteur,label=below :\scriptsize{}]{};
\node (a2) at (1,0)[acteur,label=below:\scriptsize{\hspace{0.3cm}$x_{0}$}]{};
\node (a3) at (2,0) [acteur,label=below:\scriptsize{$x_{1}$}]{};
\node (a4) at (3,0) [acteur,label=below:\scriptsize{$x_{2}$}]{};
\node (a5) at (4,0) [acteur,label=above :\scriptsize{}]{};
\node (a6) at (5,0) [acteur,label=below right :\scriptsize{\hspace{-0.9cm}$x_{k-s-t}$}]{};
\node (a7) at (6.5,0) [acteur,label=below:\scriptsize{}]{};
\node (a8) at (-0.3,-0.65) [acteur,label=above:\scriptsize{}]{};
\node (a9) at (0.4,1.3) [acteur,label=above:\scriptsize{}]{};
\node (a10) at (0.4,-1.3) [acteur,label=below:\scriptsize{}]{};
\node (a11) at (6,1) [acteur,label=below:\scriptsize{}]{};
\node (a12) at (6,-1) [acteur,label=below:\scriptsize{}]{};
\node (a13) at (5.3,1.3) [acteur,label=below:\scriptsize{}]{};
\node (a14) at (5.3,-1.3) [acteur,label=below:\scriptsize{}]{};
\draw (a1) -- (a2);
\draw (a2) -- (a9);
\draw (a2) -- (a8);
\draw (a2) -- (a10);
\draw (a2) -- (a3);
\draw (a3) -- (a4);
\draw [dashed] (a4) -- (a5);
\draw (a5) -- (a6);
\draw (a6) -- (a7);
\draw (a6) -- (a11);
\draw (a6) -- (a13);
\draw (a6) -- (a12);
\draw (a6) -- (a14);
\end{tikzpicture}
\end{center}
\caption{\small{The graph $\mathcal{P}(k,s,t)$}}
\end{figure}
You can use the decorations library
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{figure}[hbt!]
\begin{center}
\begin{tikzpicture}[
thick,
acteur/.style={
circle,
fill=black,
thick,
inner sep=2pt,
minimum size=0.2cm
}
]
\node (a1) at (-0.3,0.65) [acteur,label=below :\scriptsize{}]{};
\node (a2) at (1,0)[acteur,label=below:\scriptsize{\hspace{0.3cm}$x_{0}$}]{};
\node (a3) at (2,0) [acteur,label=below:\scriptsize{$x_{1}$}]{};
\node (a4) at (3,0) [acteur,label=below:\scriptsize{$x_{2}$}]{};
\node (a5) at (4,0) [acteur,label=above :\scriptsize{}]{};
\node (a6) at (5,0) [acteur,label=below right :\scriptsize{\hspace{-0.9cm}$x_{k-s-t}$}]{};
\node (a7) at (6.5,0) [acteur,label=below:\scriptsize{}]{};
\node (a8) at (-0.3,-0.65) [acteur,label=above:\scriptsize{}]{};
\node (a9) at (0.4,1.3) [acteur,label=above:\scriptsize{}]{};
\node (a10) at (0.4,-1.3) [acteur,label=below:\scriptsize{}]{};
\node (a11) at (6,1) [acteur,label=below:\scriptsize{}]{};
\node (a12) at (6,-1) [acteur,label=below:\scriptsize{}]{};
\node (a13) at (5.3,1.3) [acteur,label=below:\scriptsize{}]{};
\node (a14) at (5.3,-1.3) [acteur,label=below:\scriptsize{}]{};
\draw (a1) -- (a2);
\draw (a2) -- (a9);
\draw (a2) -- (a8);
\draw (a2) -- (a10);
\draw (a2) -- (a3);
\draw (a3) -- (a4);
\draw [dashed] (a4) -- (a5);
\draw (a5) -- (a6);
\draw (a6) -- (a7);
\draw (a6) -- (a11);
\draw (a6) -- (a13);
\draw (a6) -- (a12);
\draw (a6) -- (a14);
\draw[decorate,decoration={brace,amplitude=10pt}]
(-0.5, -1) -- (-0.5, 1) node[left, midway, xshift = -10pt]{$s$ vertices};
\draw[decorate,decoration={brace,amplitude=10pt}]
(6.5, 1) -- (6.5, -1) node[right, midway, xshift = 10pt]{$t$ vertices};
\end{tikzpicture}
\end{center}
\caption{\small{The graph $\mathcal{P}(k,s,t)$}}
\end{figure}
\end{document}