Tikz 双箭头样式错误

Tikz 双箭头样式错误

考虑以下 MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}


\begin{center}
\begin{tikzpicture}[every node/.style={fill=red!20,draw,double,rounded corners}]

    \node (PRR) at (0,0) {PRR};
    \node (MRR) at (2,0) {MRR};
    \node (MLL) at (2,2) {MLL};
    \node (PLL) at (0,2) {PLL};
    \node (PLR) at (4,0) {PLR};
    \node (MLR) at (6,0) {MLR};
    \node (MRL) at (6,2) {MRL};
    \node(PRL) at  (4,2) {PRL};
    \draw [latex'-latex',double] (PRR) --   [latex'-latex',double] (MRR) -- [latex'-latex',double] (MLL) -- [latex'-latex',double] (PLL) -- [latex'-latex',double] (PRR);

\end{tikzpicture}
\end{center}

\end{document}

我收到错误:

包 tikz 错误:无法解析该坐标。\draw [latex'-latex',double] (PRR) -- [

我这里犯了什么错误?

答案1

您应该为每个双向箭头创建一条新路径,因为 Tikz 只将箭头放置在路径的起点和终点。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}


\begin{center}
\begin{tikzpicture}[every node/.style={fill=red!20,draw,double,rounded corners}]

    \node (PRR) at (0,0) {PRR};
    \node (MRR) at (2,0) {MRR};
    \node (MLL) at (2,2) {MLL};
    \node (PLL) at (0,2) {PLL};
    \node (PLR) at (4,0) {PLR};
    \node (MLR) at (6,0) {MLR};
    \node (MRL) at (6,2) {MRL};
    \node(PRL) at  (4,2) {PRL};
    \begin{scope}[every path/.style={latex'-latex',double}]
        \draw (PRR) -- (MRR);
        \draw (MRR) -- (MLL);
        \draw (MLL) -- (PLL);
        \draw (PLL) -- (PRR);
    \end{scope}

\end{tikzpicture}
\end{center}

\end{document}

在此处输入图片描述

答案2

像这样使用

\begin{tikzpicture}[every node/.style={fill=red!20,draw,double,rounded corners}]

    \node (PRR) at (0,0) {PRR};
    \node (MRR) at (2,0) {MRR};
    \node (MLL) at (2,2) {MLL};
    \node (PLL) at (0,2) {PLL};
    \node (PLR) at (4,0) {PLR};
    \node (MLR) at (6,0) {MLR};
    \node (MRL) at (6,2) {MRL};
    \node(PRL) at  (4,2) {PRL};
    \draw [latex'-latex',double] (PRR);
    \draw [latex'-latex',double] (MRR);
    \draw [latex'-latex',double] (MLL);
    \draw [latex'-latex',double] (PLL);  
     \draw [latex'-latex',double] (PRR);

\end{tikzpicture} 

相关内容