在 tikzpicture 中的節點上方加入堆疊括號註釋

在 tikzpicture 中的節點上方加入堆疊括號註釋

我想在 tikzpicture 的節點上方添加堆疊括號註解。

以下是我的tex檔:

\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}

\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}

\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning}

\AtBeginDocument{%
  \DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}

\primebars
\let\emptyset\varnothing

\geometry{
 a4paper,
 margin=3cm
 }

\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath

\begin{document}
\section*{Bagan alir riset}
\vspace{5mm}

\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm]
  \node (pd) [startstop] {test};
  \node (ed) [startstop, right of=pd] {test};
  \node (ak) [startstop, right of=ed] {test};
  \node (k) [startstop, right of=ak] {test};
  \node (awk) [startstop, right of=k] {test};
  \node (s) [startstop, right of=awk] {test};

  \draw [arrow] (pd) -- (ed);
  \draw [arrow] (ed) -- (ak);
  \draw [arrow] (ak) -- (k);
  \draw [arrow] (k) -- (awk);
  \draw [arrow] (awk) -- (s);

\end{tikzpicture}
\end{adjustbox}

\end{document}

結果是這樣的排版: 在此輸入影像描述

從這個流程圖中,我想加入括號註釋,這樣: 在此輸入影像描述

其中 a、b 和 c 是文字字串。

如何透過現有的 tex 文件實現註解?

答案1

使用decorations.pathreplacing您已經載入的庫。

例子

\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}

\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}

\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning}

\AtBeginDocument{%
  \DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}

\primebars
\let\emptyset\varnothing

\geometry{
 a4paper,
 margin=3cm
 }

\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath

\begin{document}
\section*{Bagan alir riset}
\vspace{5mm}

\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm]
  \node (pd) [startstop] {test};
  \node (ed) [startstop, right of=pd] {test};
  \node (ak) [startstop, right of=ed] {test};
  \node (k) [startstop, right of=ak] {test};
  \node (awk) [startstop, right of=k] {test};
  \node (s) [startstop, right of=awk] {test};

  \draw [arrow] (pd) -- (ed);
  \draw [arrow] (ed) -- (ak);
  \draw [arrow] (ak) -- (k);
  \draw [arrow] (k) -- (awk);
  \draw [arrow] (awk) -- (s);

  \draw [decorate,decoration={brace,amplitude=8pt,raise=1em}] (ak.north west) -- (k.north east) node[midway,yshift=2.5em] {a};
  \draw [decorate,decoration={brace,amplitude=8pt,raise=1em}] (awk.north west) -- (awk.north east) node[midway,yshift=2.5em] {b};
  \draw [decorate,decoration={brace,amplitude=8pt,raise=4em}] (ak.north west) -- (awk.north east) node[midway,yshift=5.5em] {c};

\end{tikzpicture}
\end{adjustbox}

\end{document}

相關內容