
Я использую шаблон IEEE Conference 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
упаковка