Shift 花括号

Shift 花括号

我想将此 tikz 的花括号向右移动,但似乎不起作用xshift。我该如何实现?这是我的代码,在底部我添加了 tikz 的图片,其中包含我想要实现的结果。

\documentclass{article}

\usepackage{graphicx,color}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\usetikzlibrary{arrows}

\begin{document}


\begin{figure}[h!]
    \centering
    \xdefinecolor{darkgreen}{RGB}{76, 153, 0}
    \xdefinecolor{darkblue}{RGB}{0, 102, 204}
    \tikzstyle{block_blue} = [rectangle,fill=darkblue!20, draw=black, thick, align=center,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{block_green} = [rectangle,fill=darkgreen!30, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{block_orange} = [rectangle,fill=orange!20, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{line} = [draw, thick, -latex', shorten >=0pt]

    \begin{tikzpicture}[node distance=3.5em]
        \node[block_green](1) {Modell erstellen}; 
        \node[block_orange,right of=1,xshift=3.5cm](2) {TensorFlow,\\PyTorch,\\Caffe};
        \node[block_green,below of=1] (3){AI Optimierer};
        \node[block_green,below of=3] (4){AI Quantisierer};
        \node[block_green,below of=4] (5){AI Kompilierer};
        \node[block_blue,below of=5] (6){Kompiliertes Modell};
        
        \draw (1) [line]-- (3);
        \draw (3) [line]-- (4);
        \draw (4) [line]-- (5);
        \draw (5) [line]-- (6);
        \draw (2) [line]-- (1);

        \draw [decorate,decoration={brace,amplitude=5pt,raise=2ex},xshift=3cm](3.north)--node[block_orange, xshift=2.5cm]{Vitis AI}(5.south);

    \end{tikzpicture}
        \caption{Vitis AI Workflow}
        \label{fig:vitisai}
    \end{figure}


\end{document}

在此处输入图片描述

答案1

这就是目的raise所在。

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{arrows.meta}
\begin{document}
\xdefinecolor{darkgreen}{RGB}{76, 153, 0}
\xdefinecolor{darkblue}{RGB}{0, 102, 204}
\tikzstyle{block_blue} = [rectangle,fill=darkblue!20, draw=black, thick, align=center,minimum height=4ex, minimum width = 8.5em,rounded corners]
\tikzstyle{block_green} = [rectangle,fill=darkgreen!30, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
\tikzstyle{block_orange} = [rectangle,fill=orange!20, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
\tikzstyle{line} = [draw, thick, -Stealth, shorten >=0pt]
\begin{tikzpicture}[node distance=3.5em]
\node[block_green](1) {Modell erstellen}; 
\node[block_orange,right of=1,xshift=3.5cm](2) {TensorFlow,\\PyTorch,\\Caffe};
\node[block_green,below of=1] (3){AI Optimierer};
\node[block_green,below of=3] (4){AI Quantisierer};
\node[block_green,below of=4] (5){AI Kompilierer};
\node[block_blue,below of=5] (6){Kompiliertes Modell};
\draw (1) [line]-- (3);
\draw (3) [line]-- (4);
\draw (4) [line]-- (5);
\draw (5) [line]-- (6);
\draw (2) [line]-- (1);
\draw [decorate,decoration={brace,amplitude=5pt, raise=2cm}](3.north)--node[block_orange, xshift=4cm]{Vitis AI}(5.south);
\end{tikzpicture}
\end{document}

带箭头和括号的框图

答案2

实现此目的的一种方法是使用库(但不是唯一的方法)calc

移位花括号

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,decorations.pathreplacing}


\begin{document}

\begin{figure}[h!]
    \centering
    \xdefinecolor{darkgreen}{RGB}{76, 153, 0}
    \xdefinecolor{darkblue}{RGB}{0, 102, 204}
    \tikzstyle{block_blue} = [rectangle,fill=darkblue!20, draw=black, thick, align=center,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{block_green} = [rectangle,fill=darkgreen!30, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{block_orange} = [rectangle,fill=orange!20, draw=black, thick, align=center ,minimum height=4ex, minimum width = 8.5em,rounded corners]
    \tikzstyle{line} = [draw, thick, -latex', shorten >=0pt]

    \begin{tikzpicture}[node distance=3.5em]
        \node[block_green](1) {Modell erstellen}; 
        \node[block_orange,right of=1,xshift=3.5cm](2) {TensorFlow,\\PyTorch,\\Caffe};
        \node[block_green,below of=1] (3){AI Optimierer};
        \node[block_green,below of=3] (4){AI Quantisierer};
        \node[block_green,below of=4] (5){AI Kompilierer};
        \node[block_blue,below of=5] (6){Kompiliertes Modell};
        
        \draw (1) [line]-- (3);
        \draw (3) [line]-- (4);
        \draw (4) [line]-- (5);
        \draw (5) [line]-- (6);
        \draw (2) [line]-- (1);
        
        \def\xshft{2.4}
        \draw [decorate,decoration={brace,amplitude=5pt,raise=2ex}]($(3.north) + (\xshft,0)$)--node[block_orange, xshift=2.5cm]{Vitis AI}($(5.south) + (\xshft,0)$);    
    \end{tikzpicture}
    \caption{Vitis AI Workflow}
    \label{fig:vitisai}
\end{figure}
\end{document}

答案3

使用最近的tikz语法,添加chainscalligraphy库,对于节点定位使用和库chains的语法:positioning

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                decorations.pathreplacing,
                    calligraphy,% had to be loaded after decorations.pathreplacing
                positioning}

\begin{document}
    \xdefinecolor{darkgreen}{RGB}{76, 153, 0}
    \xdefinecolor{darkblue}{RGB}{0, 102, 204}
\tikzset{
    arr/.style = {draw, thick, -Latex},
    box/.style = {draw, rounded corners, thick, fill=#1, 
                  minimum height=4ex, text width = 9em,
                  align=center},
    box/.default=darkgreen!30,
     BC/.style = {% Brace Calligraphic
        decorate,
        decoration={calligraphic brace, 
                    raise=#1, amplitude=6pt},
                    very thick, thick, pen colour={black}
                },
        }% end of tikzset

    \begin{tikzpicture}[
node distance = 6mm and 12mm,
  start chain = A going below
                        ]
    \begin{scope}[nodes={box, on chain=A, join=by arr}]
\node   {Modell erstellen};         % A-1
\node   {AI Optimierer};
\node   {AI Quantisierer};
\node   {AI Kompilierer};
\node[box=darkblue!20]   {Kompiliertes Modell};
    \end{scope}
\node (A-0) [box=orange!20, right=of A-1]  {TensorFlow, PyTorch, Caffe};
%
\draw[arr]      (A-0) -- (A-1);
\draw[BC=3mm]   (A-2.north east) -- node[box=orange!20, right=9mm] {Vitis AI}
                (A-4.south east);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容