TikZ 绘图未完全显示

TikZ 绘图未完全显示

我不知道这个问题叫什么,所以很难搜索信息……当我使用tikz包装有时部分绘图无法完全显示。目前我使用的花括号代码未显示其右侧...为什么?

原始代码从我拍摄的位置来看,图片似乎显示正确。这不是我的 Textmate 第一次出现这种情况。

在此处输入图片描述

这是一个最小的工作代码,它使用我正在使用的模板并且仅显示有问题的花括号的图形:http://pastebin.com/g4j7kKAF

\documentclass{standalone}
\usepackage{tikz}
    \usetikzlibrary{matrix}
    \usetikzlibrary{decorations.pathreplacing}    
        \tikzstyle{underbrace style}=[decorate,decoration={brace,raise=10mm,amplitude=5pt,mirror},color=black]    

\usepackage[brazilian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}

      \begin{tikzpicture}[%
        >=stealth,
        shorten >=2pt,
        thick
      ]
        \matrix (block) [%
          matrix of nodes,
          nodes={%
            draw,
            anchor=center,
            minimum width=2em,
            minimum height=1em
          }
        ] {%
          1 & 2 & \node[fill=gray!99]{8}; & \node[fill=gray!50]{3}; & 4 & 6 & 9\\
        };
%\node[fill=gray!50]{1};
        \path[->] (block-1-4.north) edge [bend right=30] (block-1-3.north)
                  (block-1-3.south) edge [bend right=30] (block-1-4.south);
        \draw (block-1-1.west) node[left=0.005cm,scale=0.9] {A:};                              
        \draw (block-1-2.south) node[below=0.1cm] {$\longleftarrow$};                  
        \draw (block-1-2.south) node[left=0.2cm,below=0.4cm,scale=0.6] {Ordenado};                          
        \draw (block-1-1.north) node[above=0.1cm,scale=0.7] {0};
        \draw (block-1-2.north) node[above=0.1cm,scale=0.7] {1};
        \draw (block-1-3.north) node[above=0.1cm,scale=0.7] {i=2};
        \draw (block-1-4.north) node[above=0.05cm,scale=0.7] {j=3};
        \draw (block-1-5.north) node[above=0.1cm,scale=0.7] {4};
        \draw (block-1-6.north) node[above=0.1cm,scale=0.7] {5};
        \draw (block-1-7.north) node[above=0.1cm,scale=0.7] {6};           
        \draw (block-1-2.south east) node[right=0.25cm,below=1.9cm] {$\longrightarrow$};            
        \draw [thin] (block-1-2.south east) +(0,-2) -- +(0,+2);        
        \draw (block-1-2.south east) node[right=0.25cm,below=2.1cm] {Fronteira};    
        \draw [underbrace style] (block-1-1.south west) -- (block-1-2.south east) node [left=0.8cm,below=1.05cm] {$A_{esquerdo}$};                   
        \draw [underbrace style] (block-1-2.south east) -- (block-1-7.south east) node [left=1.8cm,below=1.05cm] {$A_{direito}$};                           

      \end{tikzpicture}
\end{document}

答案1

问题出在shorten >=2pt选项上。它使所有路径2pt变短,因此decorated 路径也比预期的短。将shorten >=0pt选项应用于underbrace样式路径,它们就会足够长。

我对你的代码做了一些更正。

  1. 最好tikzset改用tikzstyle应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?
  2. 不要\node在里面使用matrix of nodes。你可以node options用语法来更改|[options]|

您更正后的代码是:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{decorations.pathreplacing}    
\tikzset{underbrace style/.style = 
{decorate, 
 decoration={brace, raise=10mm, amplitude=5pt, mirror},
 shorten >=0pt, color=black}}
\usepackage[brazilian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}
\begin{tikzpicture}[%
        >=stealth,
        shorten >=2pt,
        thick
      ]
\matrix (block) [%
      matrix of nodes,
      nodes={%
            draw,
            anchor=center,
            minimum width=2em,
            minimum height=1em
      }
      ] 
{%
  1 & 2 & |[fill=gray!99]| 8 & |[fill=gray!50]| 3 & 4 & 6 & 9\\
};

\path[->] (block-1-4.north) edge [bend right=30] 
           (block-1-3.north)
          (block-1-3.south) edge [bend right=30] 
          (block-1-4.south);
\draw (block-1-1.west) node[left=0.005cm,scale=0.9] {A:};                              
\draw (block-1-2.south) node[below=0.1cm] {$\longleftarrow$};                  
\draw (block-1-2.south) node[left=0.2cm,below=0.4cm,scale=0.6] {Ordenado};                          
\draw (block-1-1.north) node[above=0.1cm,scale=0.7] {0};
\draw (block-1-2.north) node[above=0.1cm,scale=0.7] {1};
\draw (block-1-3.north) node[above=0.1cm,scale=0.7] {i=2};
\draw (block-1-4.north) node[above=0.05cm,scale=0.7] {j=3};
\draw (block-1-5.north) node[above=0.1cm,scale=0.7] {4};
\draw (block-1-6.north) node[above=0.1cm,scale=0.7] {5};
\draw (block-1-7.north) node[above=0.1cm,scale=0.7] {6};           
\draw (block-1-2.south east) node[right=0.25cm,below=1.9cm] {$\longrightarrow$};            
\draw [thin] (block-1-2.south east) +(0,-2) -- +(0,+2);        
\draw (block-1-2.south east) node[right=0.25cm,below=2.1cm] {Fronteira};    
\draw [underbrace style] (block-1-1.south west) -- (block-1-2.south east) node [left=0.8cm,below=1.05cm] {$A_{esquerdo}$};                   
\draw [underbrace style] (block-1-2.south east) -- (block-1-7.south east) node [left=1.8cm,below=1.05cm] {$A_{direito}$};                      
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容