# Using \emph in a Tikz \tikzstyle environment

very new to latex and Tikz. This is my first question on Tex (or any site) so apologies in advance for any mistakes or discourtesies. I'm trying to put together a process flow graphic using the code below. I want to use a tikzstyle to automatically emphasize each of the line labels so I can then put them in a table alongside and explain what is going on.

Would appreciate any help on how it might be done. [text=\textit], [font=\emph], and variations on those dont seem to work. Thanks

    \tikzstyle{action}=
[rectangle, draw, fill=blue!20, draw=blue!70, thick, inner sep=0pt, minimum width=2cm,
minimum height=1cm, text width=1.75cm, text centered, font=\footnotesize]
\tikzstyle{database}=
[cylinder, draw, fill=red!20, draw=black!70, minimum width=1.5cm, minimum height=2cm, rotate=90, text centered, font=\footnotesize]
\tikzstyle{line}=   [draw, -latex']
\tikzstyle{labe}=   [auto,font=\footnotesize,text=\textit{#1}]

\begin{tikzpicture}[scale=1.5]
%\draw [help lines] (-4,-4) grid (4,4);
\node [action] (P)              at (1,2)    {P};
\node [action](C)       at (-1,1)   {C};
\node [action](O)           at (-1,0)   {O};
\node [database](A)     at (1,0.5)  {A};
\node [action](D)           at (3,1)    {D};
\node [action](M)       at (1,-1)   {M};
\node [action](B)           at (3,-0)   {B
(Some Brokers)};
% lines
\draw [-latex'] (P.180) .. controls (-2,2) and (-4,1) .. node[auto,swap] {\emph{1}} (O.180);
\draw [-latex'] (O.80) to node [auto,right] {\emph{2}} (C.280);
\draw [-latex'] (C) to node [labe,left] {3}(O);
\draw [-latex'] (O) to (A);
\draw [-latex'] (P) to (A);
\draw [-latex'] (A.280) to (D.175);
\draw [-latex'] (D.260) to (B.100);
\draw [-latex'] (B.90) to (D.270);
\draw [-latex'] (D.190) to (A.260);
\draw [-latex'] (B) to (M);
\draw [-latex'] (M) to (A);
\end{tikzpicture}

-
You can try : font=\footnotesize\itshape. Be careful with text this option is used to give a color. Example text=red. You can use \tikzset instead of \tikzstyle. –  Alain Matthes Jul 21 '12 at 13:10
Welcome to TeX.SX! You can highlight inline code with backticks or using Ctrl+K (see How do I mark inline code?). –  Count Zero Jul 21 '12 at 13:12
Thank you Altermundus that is perfect! Thanks for the steer on inline code too Count Zero. –  Tahnoon Pasha Jul 21 '12 at 13:35

You are almost there. When you use text the xcolor package intervenes as it thinks that you want to change the color of the text (as Altermundus commented). In general you can group the options with braces (not needed here though).

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows}

\tikzset{
action/.style={rectangle, draw, fill=blue!20, draw=blue!70, thick, inner sep=0pt, minimum width=2cm,minimum height=1cm, text width=1.75cm, text centered, font=\footnotesize},
database/.style={cylinder, draw, fill=red!20, draw=black!70, minimum width=1.5cm, minimum height=2cm, rotate=90, text centered, font=\footnotesize},
line/.style={draw, -latex'},
labe/.style={font={\footnotesize\itshape}}
}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{scope}[every node/.style={action}]
\node (P)              at (1,2)    {P};
\node (C)       at (-1,1)   {C};
\node (O)           at (-1,0)   {O};
\node [database](A)     at (1,0.5)  {A};
\node (D)           at (3,1)    {D};
\node (M)       at (1,-1)   {M};
\node (B)           at (3,-0)   {B     (Some Brokers)};
\end{scope}
\begin{scope}[-latex']
\draw (P.180) .. controls (-2,2) and (-4,1) .. node[auto,swap] {\emph{1}} (O.180);
\draw (O.80) to node [auto,right] {\emph{2}} (C.280);
\draw (C) to node [labe,left] {3}(O);
\draw (O) to (A);
\draw (P) to (A);
\draw (A.280) to (D.175);
\draw (D.260) to (B.100);
\draw (B.90) to (D.270);
\draw (D.190) to (A.260);
\draw (B) to (M);
\draw (M) to (A);
\end{scope}
\end{tikzpicture}
\end{document}


Please post compilable examples next time such that we can copy paste and directly work on the example instead of guessing the missing pieces.

-
Thanks. Will post compilable in future. A quick follow on question, I notice you left out the auto option from the labe style. Is it redundant in the code? –  Tahnoon Pasha Jul 21 '12 at 13:43
@TahnoonPasha Nope, that's probably my mistake. Somehow it got lost along the way. –  percusse Jul 21 '12 at 14:28