1

I got a little automata tikzpicture but the more complex it got, the less readable it became. So I wanted to adjust the font size of the edge labels but I just can't figure out how to do that. Tried looking in the tikzpgf manual and also on here but I only find scale and fontsize for the nodes but not for the edge labels in the path commands.

For example I want to make the text in these two paths here smaller:

\usepackage{pgfplots}
\usetikzlibrary{automata,positioning,fit,shapes.geometric,backgrounds}

\begin{figure}
\begin{tikzpicture}[node distance=1.5cm]
\node  [state, initial] (Neutral)       {Neutral};   
\node[state]
    (UI Popup)
    [right=of Neutral]
    {Popped UI};

\node[state]
    (Sine)
    [above right=of UI Popup]
    [fill=gray]
    {\includegraphics[width=1.8cm]{sinecurve2}};

\node[state, circle split]
    (Digital_Off)
    [scale=0.75]
    [below right=of UI Popup]
    {Digital [Off] \nodepart{lower} \includegraphics[width=0.5cm]{pin_off}};

\node[state, circle split]
    (Digital_On)
    [scale=0.75]
    [right=of Digital_Off]
    {Digital [On] \nodepart{lower} \includegraphics[width=0.5cm]{pin_on}};

    \begin{scope}[on background layer]
\node[fit=(Digital_Off) (Digital_On), rectangle, rounded corners, draw=red, label=above:Digital state] (digital) {};
\end{scope}

\path[->] [line width=0.3mm]
            (Neutral)       edge [scale=0.2] node [above]      {Tap}                    (UI Popup)
            (UI Popup)      edge [bend left] node [above left]  {Tap and select analog} (Sine)
                            edge [bend right] node [below left] {Tap and select digital}    (Digital_Off)
            (Digital_Off)   edge [bend left] node [above]      {Tap}                    (Digital_On)
            (Digital_On)    edge [bend left] node [below]      {Tap}                    (Digital_Off)
            %(digital)      edge [bend left] node [above]      {Tap}                    (Sine)    
            (digital)       edge [bend right] node [above]     {Long click}             (UI Popup)
            (Sine)          edge [bend left]  node [below]     {Long click}             (UI Popup)
                        ;                    
\end{tikzpicture}
\caption{Input pin behavior}
\end{figure}

Edit:

This tikzpicture is in a separate file which begins with \chapter{...} and the main.tex file looks like this:

%!TEX root = ./main.tex

\documentclass[11pt, a4paper, titlepage]{book}
\include{i10preamble}
\begin{document}
\sloppy
\include{indexAddOn}

\frontmatter

\begin{titlepage}
\AddToShipoutPicture*{
\put(0,0){
\includegraphics[width=\paperwidth]{titlepage_Master_CID}}}
\strut
\end{titlepage}

% Lots of other stuff inside

\end{document}

enter image description here

7
  • 1
    can you add an MWE?
    – AndréC
    Jul 25, 2018 at 16:54
  • 1
    please show an example of your image in form of small but complete document. you can define edge node style with desired font size. or can use quotes syntax for edge labels and define font size for quotes.
    – Zarko
    Jul 25, 2018 at 16:54
  • 1
    image is welcome, but we like to see your code for it :-)
    – Zarko
    Jul 25, 2018 at 16:56
  • 1
    preamble of your document with to image related packages and used libraries are important too ...
    – Zarko
    Jul 25, 2018 at 17:00
  • by the way, your code has (many) errors. please check it again, and please provide preamble related to this image. discovering which libraries you use is not fun.
    – Zarko
    Jul 25, 2018 at 17:14

2 Answers 2

4

meanwhile i wait on your complete mwe, i test your image code in my tikz testbed, consequently my preamble can differ from what you use in your document ...

i would write code for your image on the following way:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{automata,
                fit,
                positioning,
                quotes,
                shapes.multipart
                }
\usepackage{graphicx}
\newcommand\greencirc{\tikz\node[circle, draw, thick, fill=green,
                                 minimum size=3ex, node contents={}];}
\newcommand\whitecirc{\tikz\node[circle, draw, thick, fill=white,
                                 minimum size=3ex, node contents={}];}

\begin{document}
    \begin{tikzpicture}[
node distance = 8mm and 12mm,
    MP/.style = {circle split, draw, inner sep=1pt,
                 align=center, font=\scriptsize},
state/.append style = {fill=#1, align=center},
state/.default = white,
every edge quotes/.append style={font=\scriptsize, align=center, auto}% style for edge labels
    ]
\node (Neutral)     [state, initial]            {Neutral};
\node (UI Popup)    [state, right=of Neutral]   {Popped\\ UI};
\node (Sine)        [state=gray!50, above right=of UI Popup]
    {sinecurve2};%{sinecurve2}};
\node (Digital Off) [MP, below right=of UI Popup]
        {Digital\\ {[Off]} \nodepart{lower} \\ \whitecirc};

\node (Digital On) [MP, right=of Digital Off]
        {Digital\\ {[On]} \nodepart{lower} \\  \greencirc};

%\scoped[on background layer]
\node  (digital) [rounded corners, draw=red, label=75:Digital state,
                  fit=(Digital Off) (Digital On)] {};
\path[thick, ->]
    (Neutral)       edge ["Tap"]                                    (UI Popup)
    (UI Popup)      edge [bend  left,"Tap and\\ select analog"]     (Sine)
                    edge [bend right,"Tap and\\ select digital" ']  (Digital Off)
    (Digital Off)   edge [bend left,"Tap" ']                        (Digital On)
    (Digital On)    edge [bend left,"Tap" ']                        (Digital Off)
    (digital)       edge [bend right, "Long\\ click" ']               (UI Popup)
    (Sine)          edge [bend left, "Long\\ click" ']                (UI Popup)
    ;
    \end{tikzpicture}
\end{document}

as you see, all fonts size are defined in nodes/edge quotes styles. also are replaced two images with new commands greencirc and whitecirc. similarly can be done for sine way in grayed node.

enter image description here

3
  • This looks way better than what I had, thank you! I am quite new to tikz and pgf and don't understand the styling (starting with MP/.style = ... yet but will look into it. Do you have any helpful links aside from the tikz manual which can help me get into that?
    – Someguy
    Jul 26, 2018 at 9:35
  • And also, why does ' change the position of the edge label? Or rather, where can I read into that, is that due to the quotes parameter?
    – Someguy
    Jul 27, 2018 at 11:31
  • ' is shortcut for swap, see 17.8 Placing Nodes on a Line or Curve Explicitly, page 236 (tikz & opgf manual, v 3.0.2.a.
    – Zarko
    Jul 27, 2018 at 12:38
0

Apparently scale DOES work, but I just tried it at the wrong part in the parameters.

What I tried was

    (UI Popup)      edge [scale=0.5] [bend left] node [above left]  {Tap and select analog} (Sine)

But correct would be

    (UI Popup)      edge [bend left] node [scale=0.5] [above left]  {Tap and select analog} (Sine)

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.