4

I'm using IEEE Conference Latex template. I want to have a figure with tikzpicture. My figure is not an image, is a box (rectangle) with some text inside of that. This is my code:

\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}

Problem is that,at the end, the figure crosses the first column and it has an overlap with the second column. How I can fit it to just one column?

2
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Adam Liter
    Dec 23, 2013 at 21:28
  • I think there are lot of solutions for boxing text (without the killer option TikZ); most of them are listed in How to make a code fragment in ieeetran class. Dec 24, 2013 at 9:03

1 Answer 1

5

You can either scale the node by some factor by adding e.g.

 scale=0.9

as a parameter to the node or you can break the lines by hand.

Sample output

\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}

However, a more usual way to display material like this would be to use e.g. the listings package

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .