10

I'm drawing Petri nets with TikZ. But, according to the style I've defined, transitions are rectangle nodes with a 1:1 ratio (squares, actually).

I'm very used to have more flat transitions, but I can't figure out how to set their default height. I've tried something using yscale, but this affects the distance between nodes.

\documentclass[a4paper, 12pt]{article}
\usepackage{tikz}
\usetikzlibrary{petri}
\tikzstyle{place}= [circle, draw=blue!50, fill=blue!20, thick, minimum size=0.6cm]
\tikzstyle{transition}= [rectangle, draw=black!50, fill=black!20, thick, minimum size=0.6cm]
\tikzstyle{pre}=    [<-, semithick]
\tikzstyle{post}=   [->, semithick]

\begin{document}
\begin{figure}[h]
\begin{center}
    \begin{tikzpicture}[node distance=2cm]
            \node[place] (p1){};
            \node[transition] (t1) [below of=p1]{}
                edge[pre] (p1);
            \node[place] (p2) [below of=t1]{};
            \node[transition] (t2) [below of=p2]{}
                edge[pre] (p2);
    \end{tikzpicture}
    \caption{Train n°1}
\end{center}
\end{figure}
\end{document}
1
  • minimum height=<dimen> is what you are looking for?. minimum size fixes both height and width while minimum width is for only width.
    – user11232
    Dec 7, 2014 at 11:36

1 Answer 1

17

Some thing like this?

\documentclass[a4paper, 12pt]{article}
\usepackage{tikz}
\usetikzlibrary{petri}
\tikzset{place/.style = {circle, draw=blue!50, fill=blue!20, thick, minimum size=0.6cm},
    transition/.style = {rectangle, draw=black!50, fill=black!20, thick, minimum width=0.6cm,
                        minimum height = 1cm},
    pre/.style =    {<-, semithick},
    post/.style =   {->, semithick}
}

\begin{document}
\begin{figure}[h]
\begin{center}
    \begin{tikzpicture}[node distance=2cm]
            \node[place] (p1){};
            \node[transition] (t1) [below of=p1]{}
                edge[pre] (p1);
            \node[place] (p2) [below of=t1]{};
            \node[transition] (t2) [below of=p2]{}
                edge[pre] (p2);
    \end{tikzpicture}
    \caption{Train n°1}
\end{center}
\end{figure}
\end{document}

enter image description here

minimum size sets both width and height to be equal so you get a square. Instead you can set width and height separately by minimum width=<dimen> and minimum height = <dimen>.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .