2

I'd like to be able to achieve the following colouring of the arrow of an "accepting by arrow" node, but on a node-by-node basis, rather than globally:

enter image description here

From this question I was able to see how to set the arrow style globally, but my Tikz knowledge is quite basic, and I wasn't able to figure out how to set the colour of the accepting arrow for a particular node. (Setting the node colour to red doesn't change the colour of the accepting arrow.)

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata}

\tikzset{positive/.style={circle,red,minimum width=8pt,draw}}

\begin{document}
\begin{tikzpicture}[every accepting by arrow/.style={red}]
\node[positive,initial,initial text=,accepting by arrow] (A) {};
\end{tikzpicture}
\end{document}
0

1 Answer 1

1

You could modify the \newTransition macro of the post you linked.

The parameters I used are:

  1. starting node name
  2. ending (fake) node name
  3. position of the fake node
  4. color of the arrow.

Here is an MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata, positioning}
\newcommand{\newTransition}[4]{\coordinate[#3 of #1] (#2);\draw[->] (#1) edge [#4] node {} (#2);} 

\tikzset{positive/.style={circle,minimum width=8pt,draw}}

\begin{document}
    \begin{tikzpicture}
        \node[positive, initial, initial text=, accepting by arrow] (A) {};% benchmark with no colors
        \node[positive, initial, initial text=, red, below = of A] (B) {};
        \newTransition{B}{dummy1}{right =1.3em}{green}
        \node[positive, initial, initial text=, blue, below = of B] (C) {};
        \newTransition{C}{dummy2}{right =1.3em}{orange}
    \end{tikzpicture}
\end{document}

And here is the results (the first one is without colors as benchmark):

enter image description here

You must log in to answer this question.

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