Tabellen und Grafiken erstellen und anordnen
olpo
Forum-Anfänger
Beiträge: 15 Registriert: Fr 1. Sep 2017, 19:10
Beitrag
von olpo » Fr 1. Sep 2017, 19:16
Hallo,
das Maus-Geklicke bei MS Visio strapaziert meine Nerven sehr stark, deshalb wollte ich nochmal einen Versuch mit Tikz starten.
Leider bin ich schon etwas im Verzug, weshalb ich nicht groß Dokus studieren kann...
Ich würde gerne das Bild im Anhang als schöne Tikz Grafik bauen.
Ich dachte, ich fange mit der oberen Blöcken an. Ich habe die schon erstellt. Aber wie platziere ich die jetzt in gleichen Abstand nebeneinander?
\documentclass{article}
\usepackage[british]{babel}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
nodes=draw,
block/.style={minimum height=6em, minimum width=9em} ]
\node[block](c1){Client 1};
\node[block](c2){Client 2};
\node[block](s1){Server 2};
\node[block](s2){Server 2};
\node[block](s2){Database};
\end{tikzpicture}
\end{document}
Danke.
Dateianhänge
tikz.pdf
(152.87 KiB) 253-mal heruntergeladen
Bartman
Forum-Meister
Beiträge: 2456 Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz
Beitrag
von Bartman » Fr 1. Sep 2017, 19:33
Eine Möglichkeit wäre z. B. der Einsatz der positioning-Bibliothek.
Dafür gibt es schon am Anfang der Anleitung Beispiele in dem Tutorium über Petri-Netze.
In Deinem Beispiel könnte die Platzierung der beiden Clients so aussehen:
\documentclass[tikz, border=5pt]{standalone}
\usepackage[british]{babel}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
nodes=draw,
block/.style={minimum height=6em, minimum width=9em}
]
\node[block](c1){Client 1};
\node[block, right=of c1](c2){Client 2};
% \node[block](s1){Server 2};
% \node[block](s2){Server 2};
% \node[block](s2){Database};
\end{tikzpicture}
\end{document}
olpo
Forum-Anfänger
Beiträge: 15 Registriert: Fr 1. Sep 2017, 19:10
Beitrag
von olpo » Fr 1. Sep 2017, 19:59
Ok, sieht auf dem ersten Blick ganz gut aus.
Aber bekomme ich den großen Block "OS" damit auch hin?
Der soll am besten so breit sein, daß er auf der gleichen X-Achse mit "Client 1" anfängt und auf Höhe der rechten Seite von "Server 2" aufhört.
Geht das?
\documentclass{article}
\usepackage[british]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
nodes=draw,
block/.style={minimum height=6em, minimum width=9em} ]
\node[block](c1){Client 1};
\node[block, right=of c1] (c2) {Client 2};
\node[block, right=of c2] (s1) {Server 2};
\node[block, right=of s1] (s2) {Server 2};
% \node[block](d){Database};
\end{tikzpicture}
\end{document}
olpo
Forum-Anfänger
Beiträge: 15 Registriert: Fr 1. Sep 2017, 19:10
Beitrag
von olpo » Sa 2. Sep 2017, 16:31
Kann ich denn nicht mit c1.west und s2.east, oder so, auf die Eckkoordinaten zugreifen?
Und dann meinen OS-Block von c1.west bis s2.east zeichnen?
Beinschuss
Forum-Meister
Beiträge: 809 Registriert: Di 2. Okt 2012, 21:42
Wohnort: NRW
Beitrag
von Beinschuss » Sa 2. Sep 2017, 17:19
Eine Möglichkeit (es gibt bestimmt elegantere):
\documentclass{article}
\usepackage[british]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
block/.style={minimum height=3em, minimum width=9em, draw=black},
breit/.style={minimum height=6em, minimum width=40em, draw=black},
pfeil/.style={->, shorten >=1pt, thick}}
\begin{document}
\begin{tikzpicture}
\node[block](c1){Client 1};
\node[block, right=of c1] (c2) {Client 2};
\node[block, right=of c2] (s1) {Server 2};
\node[block, right=of s1] (s2) {Server 2};
\node[breit, below=of c2, xshift=6em] (os) {OS};
\draw[pfeil] (c1.south) |- (3,-2.3) -| (s1.south);
\draw[pfeil] (c2.south) |- (5,-2) -| ([xshift=1em]s1.south west);
\node[block, below=5cm of s2](d){Database};
\end{tikzpicture}
\end{document}
Ich habe Dir auch schon mal zwei Pfeile eingezeichnet ...
esdd
Forum-Meister
Beiträge: 2561 Registriert: So 7. Feb 2010, 16:36
Beitrag
von esdd » So 3. Sep 2017, 00:06
Und hier noch eine Möglichkeit, wie man die nötige Breite berechnen lassen kann:
\documentclass{article}
\usepackage[british]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\tikzset{
block/.style={minimum height=3em, minimum width=9em, draw=black},
breit/.style={minimum height=6em,
minimum width=#1,
draw=black},
pfeil/.style={->, shorten >=1pt, thick}}
\begin{document}
\begin{tikzpicture}
\node[block](c1){Client 1};
\node[block, right=of c1] (c2) {Client 2};
\node[block, right=of c2] (s1) {Server 2};
\node[block, right=of s1] (s2) {Server 2};
\path let \p1=(c1.west), \p2=(s2.east) in
node[breit={\x2-\x1}, below=of c1.south west, anchor=north west] (os) {}
(os.south west) node[above right,outer sep=1em] {OS};
\draw[pfeil] (c1.south) |- (3,-2.3) -| (s1.south);
\draw[pfeil] (c2.south) |- (5,-2) -| ([xshift=1em]s1.south west);
\node[block, below=5cm of s2](d){Database};
\end{tikzpicture}
\end{document}
Bartman
Forum-Meister
Beiträge: 2456 Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz
Beitrag
von Bartman » So 3. Sep 2017, 15:00
Mein Vorschlag enthält hauptsächlich nur Empfehlungen:
\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\tikzset{
nodes={font=\sffamily},
blockrand/.style={
draw,
rounded corners,
thick
},
block/.style={
blockrand,
minimum height=3em,
minimum width=9em
},
breit/.style={
blockrand,
minimum height=6em,
minimum width=#1
},
pfeil/.style={
-{Stealth[length=2mm,width=3mm]},
shorten >=1pt,
rounded corners,
ultra thick
}
}
\begin{document}
\begin{tikzpicture}
\node[block](c1){Client 1};
\node[block, right=of c1] (c2) {Client 2};
\node[block, right=of c2] (s1) {Server 1};
\node[block, right=of s1] (s2) {Server 2};
\node[block, below=5cm of s2] (d) {Database};
\path let \p1=(c1.west), \p2=(s2.east) in
node[breit={\x2-\x1}, below=of c1.south west, anchor=north west] (os) {}
(os.south west) node[above right,outer sep=1em] {OS};
\draw[pfeil] (c1.south) -- ++ (0,-5em) -| (s1.south);
\draw[pfeil] (c2.south) -- ++ (0,-4em) -| ([xshift=-2em]s1.south);
\draw[pfeil] ([xshift=2em]s1.south) -- ++ (0,-6em) -| ([xshift=-1.5em]s2.south);
\draw[pfeil] ([xshift=1.5em]s2.south) -- ([xshift=1.5em]d.north);
\path (os) -- coordinate (halberweg) (d);
\draw[dashed]
([xshift=-2.5cm]current bounding box.west|-halberweg) --
node [pos=.03, above=1em] {SW}
node [pos=.03, below=1em] {HW}
(current bounding box.east|-halberweg)
;
\end{tikzpicture}
\end{document}