Graphics, Figures & Tables ⇒ Boxes and Arrows
-
- Posts: 11
- Joined: Sun Nov 18, 2012 8:20 pm
Boxes and Arrows
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Boxes and Arrows
Two possible packages.clarinetist wrote:How would this be done in LaTeX? […]
With this information you can start on your own and present code for corrections if necessary.
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 11
- Joined: Sun Nov 18, 2012 8:20 pm
Boxes and Arrows
Code: Select all
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\begin{document}
\begin{center}
%\begin{tikzpicture}[every text node part/.style={align=center}] used for multiple parts,
%along with shapes.multipart tikz library.
\begin{tikzpicture}[sharp corners=2pt,inner sep=7pt,node distance=.8cm,every text node part/.style={align=center}]
% Draw rectangular nodes (switch sharp to smooth for different corners)
\node[draw, minimum height = 4cm, minimum width = 4cm] (state0){\textbf{0} \\ \\
$(x)$ and $(y)$ \\ both alive};
\node[draw,below=2cm of state0, minimum height = 4cm, minimum width = 4cm](state2){\textbf{2} \\ \\
Only $(y)$ is alive};
\node[draw,right=2cm of state0, minimum height = 4cm, minimum width = 4cm](state1){\textbf{1} \\ \\
Only $(x)$ is alive};
\node[draw,below=2cm of state1, minimum height = 4cm, minimum width = 4cm](state3){\textbf{3} \\ \\
$(x)$ and $(y)$ \\ both dead};
%Draw arrows
\draw[-triangle 60] (state0) -- (state2) node [midway, above, left = 0.1cm]{$\mu^{02}_{x+t:y+t}$};
\draw[-triangle 60] (state0) -- (state1) node [midway, above]{$\mu^{01}_{x+t:y+t}$};
\draw[-triangle 60] (state1) -- (state3) node [midway, above, right = 0.1cm]{$\mu^{13}_{x+t:y+t}$};
\draw[-triangle 60] (state2) -- (state3) node [midway, above]{$\mu^{23}_{x+t:y+t}$};
\draw[-triangle 60] (state0) -- (state3) node [midway, above, rotate = -45]{$\mu^{03}_{x+t:y+t}$};
\end{tikzpicture}
\end{center}
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Boxes and Arrows
Yes. And you already do so successfully. Hence I don't see the problem. What exactly is the questions here?clarinetist wrote:[…] Is there any way I can guarantee that the shapes are squares with some length and width? (i.e., can I control the length and width of the squares without "minimum height" and "minimum width"?)
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 11
- Joined: Sun Nov 18, 2012 8:20 pm
Boxes and Arrows
Code: Select all
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\begin{document}
\begin{center}
%\begin{tikzpicture}[every text node part/.style={align=center}] used for multiple parts,
%along with shapes.multipart tikz library.
\begin{tikzpicture}[sharp corners=2pt,inner sep=7pt,node distance=.8cm,every text node part/.style={align=center}]
% Draw rectangular nodes (switch sharp to smooth for different corners)
\node[draw, minimum height = 3cm, minimum width = 3cm] (state0){\textbf{0} \\ \\
$(x)$ and $(y)$ \\ both alive};
\node[draw,below=2cm of state0, minimum height = 3cm, minimum width = 3cm](state2){\textbf{2} \\ \\
Only $(y)$ is alive};
\node[draw,right=2cm of state0, minimum height = 3cm, minimum width = 3cm](state1){\textbf{1} \\ \\
Only $(x)$ is alive};
\node[draw,below=2cm of state1, minimum height = 3cm, minimum width = 3cm](state3){\textbf{3} \\ \\
$(x)$ and $(y)$ \\ both dead};
%Draw arrows
\draw[-triangle 60] (state0) -- (state2) node [midway, above, left = 0.1cm]{$\mu^{02}_{x+t:y+t}$};
\draw[-triangle 60] (state0) -- (state1) node [midway, above]{$\mu^{01}_{x+t:y+t}$};
\draw[-triangle 60] (state1) -- (state3) node [midway, above, right = 0.1cm]{$\mu^{13}_{x+t:y+t}$};
\draw[-triangle 60] (state2) -- (state3) node [midway, above]{$\mu^{23}_{x+t:y+t}$};
\draw[-triangle 60] (state0) -- (state3) node [midway, above, rotate = -45]{$\mu^{03}_{x+t:y+t}$};
\end{tikzpicture}
\end{center}
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Boxes and Arrows
The size of a node primarily orientates itself towards the size of its content. If the content is small, the minimum size specifications are active (by the keysclarinetist wrote:What I mean is, is there a way for me to specify the dimensions of the nodes without the "minimum" parameters? For example, if I switched the dimensions to 3cm (code is below), the squares are no longer the same size. […]
minimum size
, minimum width
, minimum height
). If the content is bigger than the specified minimum dimensions, the concerned node will grow and so it can happen that nodes have different sizes.Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 11
- Joined: Sun Nov 18, 2012 8:20 pm
Boxes and Arrows
Thank you for your help!localghost wrote:The size of a node primarily orientates itself towards the size of its content. If the content is small, the minimum size specifications are active (by the keysminimum size
,minimum width
,minimum height
). If the content is bigger than the specified minimum dimensions, the concerned node will grow and so it can happen that nodes have different sizes.
