Graphics, Figures & Tables ⇒ How to create an ergonomic diagram in tikz?
How to create an ergonomic diagram in tikz?
Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.
- Attachments
-
- ergonomic.png (6.64 KiB) Viewed 3661 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
How to create an ergonomic diagram in tikz?
I would begin by modifying the code for one of the examples located at
http://www.texample.net/tikz/examples/tag/diagrams/.
Tom
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to create an ergonomic diagram in tikz?
It is possible with pgf/tikZ and some of its additional libraries.usr345 wrote:I am very interested in created ergonomic diagrams. But MS Visio is evil. Can someone help me to do this in tikZ?
My first idea was the following which gave me two errors and bad box warnings. It was simple and flexible, but didn't result in the output as shown in the picture.
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,fit,positioning,shapes,shapes.callouts}
\begin{document}
\begin{tikzpicture}[%
shorten >=3pt,
shorten <=3pt,
node distance=5cm,
note/.style={draw,fill=white,rectangle callout,minimum width=10em,minimum height=4ex},
content/.style={draw,fill=white,ellipse,minimum width=10em,minimum height=4ex}
]
\node[content] (a) {Let's go to bed};
\node[content] (b) [right of=a] {said Vasya};
\node[note,callout absolute pointer={(a.north)}] (c) [node distance=1.5cm,above of=a] {Direct speech\strut};
\node[note,callout absolute pointer={(b.north)}] (d) [right of=c] {Author's words\strut};
\path (a) edge (b);
\begin{scope}[on background layer]
\node[draw,fill=gray!25,fit=(a) (b) (c) (d)] {};
\node[draw,fill=gray!10,fit=(a) (b)] {};
\end{scope}
\end{tikzpicture}
\end{document}
Code: Select all
! Undefined control sequence.
\pgf@sh@bg@rectangle callout ...f@sh@np@\pgf@test
\noexpand \endcsname }\ede...
l.15 ...e=1.5cm,above of=a] {Direct speech\strut};
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\pgf@sh@bg@rectangle callout ...f@sh@np@\pgf@test
\noexpand \endcsname }\ede...
l.16 ... {Author's words\strut};
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
So here is another example that does exactly what the picture shows without any warnings or errors.
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,positioning,shapes,shapes.callouts}
\begin{document}
\begin{tikzpicture}[%
shorten >=3pt,
shorten <=3pt,
node distance=5cm,
note/.style={draw,fill=white,rectangle callout,minimum width=10em,minimum height=4ex},
content/.style={draw,fill=white,ellipse,minimum width=10em,minimum height=4ex}
]
\node[content] (a) {Let's go to bed};
\node[content] (b) [right of=a] {said Vasya};
\node[note,callout relative pointer={(0,-0.75)}] (c) [node distance=1.5cm,above of=a] {Direct speech\strut};
\node[note,callout relative pointer={(0,-0.75)}] (d) [right of=c] {Author's words\strut};
\path (a) edge (b);
\begin{scope}[on background layer]
\draw[fill=gray!25] ($(c.north west)+(-20pt,15pt)$) rectangle ($(d.south east)+(20pt,-65pt)$);
\draw[fill=gray!10] ($(a.south west)+(-20pt,-10pt)$) rectangle ($(b.north east)+(20pt,10pt)$);
\end{scope}
\end{tikzpicture}
\end{document}
*Perhaps you want to send a bug report to the package maintainer(s) if you can reproduce the error.
Thorsten
- Attachments
-
- The resulting output of the second example.
- ergonomic.png (8.97 KiB) Viewed 3619 times
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10