使用 Tikzpicture 添加字幕

使用 Tikzpicture 添加字幕

我正在尝试在乳胶中为以下流程图添加标题,但目前还没有成功。如能得到任何帮助我将不胜感激。

\documentclass[a4paper, 10pt, conference]{ieeeconf}      % Use this line for a4 paper
\IEEEoverridecommandlockouts                              % This command is only    needed if 
                                                      % you want to use the \thanks  command
\overrideIEEEmargins      
\usepackage{graphicx} % for pdf, bitmapped graphics files
\usepackage{times} % assumes new font selection scheme installed
\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb}  % assumes amsmath package installed
\usepackage{grffile}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}

\begin{document}

\newcommand\captionof[1]{\def\@captype{#1}\OrigCaption}
\tikzstyle{decision} = [diamond, draw, aspect =2, fill=pink!15,
text width=6em, text badly centered, node distance=4.5cm, inner sep=2pt]
\tikzstyle{block} = [rectangle, rounded corners, draw = blue, thick, fill=blue!16,
text width=9em, text centered, minimum height=3em]
\tikzstyle{line} = [draw, very thick, color=black!60, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=purple!20, node distance=3.0cm,
minimum height=1em]

\begin{figure}[h]
\begin{tikzpicture}[scale=4, node distance = 1.4cm, auto]
% Place nodes
\node [block] (init) {Construct and Save an OpenNI Depth Context};
\node [cloud, left of=init, node distance=4cm] (start) {Initialization};
\node [block, below of=init, node distance=1.6cm] (DepthGen) {Create a Depth      Generator};
\node [block, below of=DepthGen, node distance=1.6cm] (MapOutput) {Create a Depth Data Map};
\node [block, left of=MapOutput, node distance=4cm] (update) {Continuously Update Depth Images in Context Map};
\node [block, below of=MapOutput, node distance=1.6cm] (MapResolution) {Get 2D map resolution coordinates};
\node [block, below of=MapResolution, node distance=1.6cm] (Midpoint) {Retrieve midpoint of depth coordinates};
\node [block, below of=Midpoint, node distance=1.6cm] (send) {Send coordinates to myRIO via UDP packets};
\node [decision, below of=send, node distance=2.2cm] (decide) {Missing Frame Data?};
\node [block, left of=decide, node distance=4.5cm] (Yes) {Use previous frame's depth data};
\node [block, below of=decide, node distance=2.1cm] (no) {Apply FIR point-by-point filter};
\node [block, below of=no, node distance=1.6cm] (Use) {Pass on measurement data to control patient head};

% Draw edges
\path [line] (init) -- (DepthGen);
\path [line, dashed] (DepthGen) - | (update);
\path [line, dashed] (start) -- (init);
\path [line] (DepthGen) -- (MapOutput);
\path [line] (MapOutput) -- (MapResolution);
\path [line] (MapResolution) -- (Midpoint); 
\path [line] (Midpoint) -- (send); 
\path [line] (send) -- (decide); 
\path [line] (decide) -- (no); 
\path [line] (decide) -- node [near start, color=black] {Yes} (Yes);
\path [line] (decide) -- node [near start, color=black] {No} (no);
\path [line, dashed] (Yes) |- (no);
\path [line] (no) -- (Use);

\end{tikzpicture} 

\caption{Vision Algorithm Flowchart}
\label{Fig. 3.}


\end{figure}

\end{document}

我也尝试过使用该\captionof{some caption}命令,但没有成功。非常感谢您的见解!

答案1

答案如下:

\documentclass[a4paper, 10pt, conference]{ieeeconf}      % Use this line for a4 paper
\IEEEoverridecommandlockouts                              % This command is only       needed if 
                                                  % you want to use the \thanks  command
\overrideIEEEmargins      
\usepackage{graphicx} % for pdf, bitmapped graphics files
\usepackage{times} % assumes new font selection scheme installed
\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb}  % assumes amsmath package installed
\usepackage{grffile}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}

\begin{document}

\tikzstyle{decision} = [diamond, draw, aspect =2, fill=pink!15,
text width=6em, text badly centered, node distance=4.5cm, inner sep=2pt]
\tikzstyle{block} = [rectangle, rounded corners, draw = blue, thick, fill=blue!16,
text width=9em, text centered, minimum height=3em]
\tikzstyle{line} = [draw, very thick, color=black!60, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=purple!20, node distance=3.0cm,
minimum height=1em]

% Draw Flowchart of Vision Program
\begin{minipage}{\columnwidth}\begin{center}
\begin{tikzpicture}[scale=4, node distance = 1.4cm, auto]
% Place nodes
\node [block] (init) {Construct and Save an OpenNI Depth Context};
\node [cloud, left of=init, node distance=4cm] (start) {Initialization};
\node [block, below of=init, node distance=1.6cm] (DepthGen) {Create a Depth      Generator};
\node [block, below of=DepthGen, node distance=1.6cm] (MapOutput) {Create a Depth Data Map};
\node [block, left of=MapOutput, node distance=4cm] (update) {Continuously Update Depth Images in Context Map};
\node [block, below of=MapOutput, node distance=1.6cm] (MapResolution) {Get 2D map resolution coordinates};
\node [block, below of=MapResolution, node distance=1.6cm] (Midpoint) {Retrieve midpoint of depth coordinates};
\node [block, below of=Midpoint, node distance=1.6cm] (send) {Send coordinates to myRIO via UDP packets};
\node [decision, below of=send, node distance=2.2cm] (decide) {Missing Frame Data?};
\node [block, left of=decide, node distance=4.5cm] (Yes) {Use previous frame's depth data};
\node [block, below of=decide, node distance=2.1cm] (no) {Apply FIR point-by-point filter};
\node [block, below of=no, node distance=1.6cm] (Use) {Pass on measurement data to control patient head};

% Draw edges
\path [line] (init) -- (DepthGen);
\path [line, dashed] (DepthGen) - | (update);
\path [line, dashed] (start) -- (init);
\path [line] (DepthGen) -- (MapOutput);
\path [line] (MapOutput) -- (MapResolution);
\path [line] (MapResolution) -- (Midpoint); 
\path [line] (Midpoint) -- (send); 
\path [line] (send) -- (decide); 
\path [line] (decide) -- (no); 
\path [line] (decide) -- node [near start, color=black] {Yes} (Yes);
\path [line] (decide) -- node [near start, color=black] {No} (no);
\path [line, dashed] (Yes) |- (no);
\path [line] (no) -- (Use);

\end{tikzpicture} 
\captionof{figure}{Vision Algorithm Flowchart}
\label{Fig. 3.}
\end{center}\end{minipage}
% end of flowchart code 

相关内容