IEEE latex 模板。如何使用 tikzpicture 将图形放入一列中?

IEEE latex 模板。如何使用 tikzpicture 将图形放入一列中?

我正在使用 IEEE Con​​ference Latex 模板。我想要一个带有 的图形tikzpicture。我的图形不是图像,而是一个里面有一些文本的框(矩形)。这是我的代码:

\begin{figure}[t]
\begin{tikzpicture}
\node [draw,rectangle,align=left,right=2pt] (mid) 
            {\textless bug\textgreater\\
            \textless \texttt{bug\_id}\textgreater 175229\textless \texttt{/bug\_id}\textgreater\\ 
           \textless \texttt{creation\_ts}\textgreater 2007-02-23 03:34:00 \textless\texttt{/creation\_ts}\textgreater\\ 
            \textless \texttt{short\_desc}\textgreater\\ 
                \hspace*{0.1in}
Should be able to open editor automatically when a task is activated\\ 
            \textless \texttt{/short\_desc}\textgreater\\ 
           \textless /bug\textgreater\\ 
          .......................................................................... };

\end{tikzpicture}
\captionsetup{justification=centering}
\caption{The overall structure of approach}
\end{figure}

问题是,最后,图形穿过第一列,并与第二列重叠。我怎样才能将其放入一列中?

答案1

您可以通过添加例如来按某个因子缩放节点

 scale=0.9

作为节点的参数,或者您可以手动断线。

示例输出

\documentclass[conference]{IEEEtran}

\usepackage{tikz,caption}

\usepackage{lipsum}

\begin{document}

\title{Sample document}

\author{\IEEEauthorblockN{A. Author}
\IEEEauthorblockA{Address\\City}}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}

\lipsum[1-2]

\begin{figure}[t]
\centering
\begin{tikzpicture}
\node [draw,rectangle,align=left,right=2pt,scale=0.8] (mid) 
            {\textless bug\textgreater\\
            \textless \texttt{bug\_id}\textgreater 175229\textless \texttt{/bug\_id}\textgreater\\ 
           \textless \texttt{creation\_ts}\textgreater 2007-02-23 03:34:00 \textless\texttt{/creation\_ts}\textgreater\\ 
            \textless \texttt{short\_desc}\textgreater\\ 
                \hspace*{0.1in}
Should be able to open editor automatically when a task is activated\\ 
            \textless \texttt{/short\_desc}\textgreater\\ 
           \textless /bug\textgreater\\ 
          .......................................................................... };

\end{tikzpicture}
\captionsetup{justification=centering}
\caption{The overall structure of approach}
\end{figure}

\begin{figure}[t]
\centering
\begin{tikzpicture}
\node [draw,rectangle,align=left,right=2pt] (mid) 
            {\textless bug\textgreater\\
            \textless \texttt{bug\_id}\textgreater 175229\textless \texttt{/bug\_id}\textgreater\\ 
           \textless \texttt{creation\_ts}\textgreater 2007-02-23 03:34:00 \\\textless\texttt{/creation\_ts}\textgreater\\ 
            \textless \texttt{short\_desc}\textgreater\\ 
                \hspace*{0.1in}
                Should be able to open editor automatically when a task\\
                \hspace*{0.1in}is activated\\ 
            \textless \texttt{/short\_desc}\textgreater\\ 
           \textless /bug\textgreater\\ 
          .......................................................................... };

\end{tikzpicture}
\captionsetup{justification=centering}
\caption{The overall structure of approach}
\end{figure}

\lipsum[2-4]
\end{document}

然而,显示此类材料的更常见方式是使用例如listings包裹

相关内容