在 Tikz \tikzstyle 环境中使用 \emph

在 Tikz \tikzstyle 环境中使用 \emph

我对 latex 和 Tikz 非常陌生。这是我在 Tex(或任何网站)上的第一个问题,因此对于任何错误或失礼之处,请提前致歉。我正在尝试使用以下代码组合流程图。我想使用tikzstyle自动强调每个行标签,这样我就可以将它们放在旁边的表格中并解释发生了什么。

非常感激任何关于如何完成的帮助。[text=\textit][font=\emph]和这些变体似乎不起作用。谢谢

    \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}

答案1

您几乎已经完成了。当您使用text包时xcolor,它会进行干预,因为它认为您想要更改文本的颜色(正如 Altermundus 所评论的那样)。通常,您可以使用括号将选项分组(但这里不需要)。

\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}

在此处输入图片描述

下次请发布可编译的示例,以便我们可以复制粘贴并直接处理示例,而不必猜测缺失的部分。

相关内容