5

I'm following TikZ & PGF Manual, on page 47 (drawing a Petri net). The example is demonstrating making every label red with the following line:

\begin{tikzpicture}[every label/.style={red}]

When I use this the label does turn red, but I lose all other color: enter image description here

(and here is my image without the [every label/.style={red}] portion):

enter image description here

My log contains a bunch of lines like this:

Missing character: There is no [ in font nullfont!
Missing character: There is no p in font nullfont!
Missing character: There is no l in font nullfont!

This question suggests that blank lines are the cause, but my image works when I remove the [every label/.style={red}] portion, and doesn't when I put it back. This question suggests that I've got bare text. I'm afraid I don't know enough to determine whether this is the case for me (but I am copying from the linked manual...).

Could somebody shed light on this issue? Here's my minimal non-working example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning, fit,petri}
\begin{document}
\begin{tikzpicture}[every label/.style={red}]
    [place/.style={circle,draw=blue!50,fill=blue!20,thick,
                    inner sep=0pt, minimum size=6mm},
    transition/.style={rectangle,draw=black!50,fill=black!20,thick,
                    inner sep=0pt, minimum size=4mm}]
    %
    \node [place] (waiting) at ( 0,2)   {};
    \node [place] (critical) at ( 0,1)  [below=of waiting]  {};
    \node [place] (semaphore) at ( 0,0) [below=of critical,label=above:$s\le3$] {};
    \node [transition] (leave critical) at ( 1,1) [right=of critical]  {};
    \node [transition] (enter critical) at (-1,1) [left =of critical]  {};
\end{tikzpicture}
\end{document}
6

Got it.

\begin{tikzpicture}[every label/.style={red}]
    [place/.style={circle,draw=blue!50,fill=blue!20,thick,
                    inner sep=0pt, minimum size=6mm},
    transition/.style={rectangle,draw=black!50,fill=black!20,thick,
                    inner sep=0pt, minimum size=4mm}]

This has two style setup sections (two sections in [ ]). One of them (the second) is being interpreted as bare text, instead of an addendum to the first. Because the second set contains the color for the nodes, they weren't being colored.

To fix this, I should just use a single [ ... ] containing all my styling:

\begin{tikzpicture}[every label/.style={red},
                   place/.style={circle,draw=blue!50,fill=blue!20,thick,
                         inner sep=0pt,minimum size=6mm},
                   transition/.style={rectangle,draw=black!50,fill=black!20,thick,
                         inner sep=0pt,minimum size=4mm}]
| improve this answer | |
  • 6
    To give an explanation for the warning message: PGF/TikZ ignores all text inside their picture environments because the content is only built from the drawing code. To ignore the text a special empty font "nullfont" is set which doesn't produce any output for text but gives you the warning "There is no .. in font nullfont!". In addition the whole content is stored in a box which is then discared. (The drawing code is added to a differnt box which is then placed.) – Martin Scharrer Jun 26 '13 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.