Tikz 逐项列出行间距

Tikz 逐项列出行间距

我有一张图表,tikz其中每个节点包含一个逐项列表。

\documentclass[11pt, authoryear, 3p]{elsarticle}

\usepackage{tikz}
\usetikzlibrary{shapes,positioning,arrows}

\begin{document}

\begin{figure}
\tikzstyle{dataset} = [rectangle, draw, text width = 2in, minimum height=1in, ]
\begin{tikzpicture}[auto, font=\scriptsize]
    % Place nodes
    \node [dataset] (tm) {Data 1 \begin{itemize}
            \item{\# Adults } \item{\# Children} \item{Income} 
            \item{Ethnicity}
          \end{itemize}};
    \node [dataset, right of=tm, node distance=3in] (dmv) {Data 2 \begin{itemize} \item{Data 2} \end{itemize}};
    % draw links
    \path [<->] (tm) edge node[above, sloped] {Address} (dmv);
\end{tikzpicture}
    \caption{Analysis dataset assembly.}
    \label{fig:dataset}
\end{figure}


\end{document} 

输出

这些项目是双倍行距的,与文档的其余部分一样。如何将这些节点设置为单倍行距?我尝试将块封装在环境中singlespaced,相关问题(例如,这个) 似乎并不完全适用。

答案1

像这样?

\documentclass[11pt, authoryear, 3p]{elsarticle}

\usepackage{tikz,enumitem,setspace,kantlipsum}
\usetikzlibrary{shapes,positioning,arrows}

\begin{document}
\doublespacing
\kant[1]
\begin{figure}[htb]
\tikzset{dataset/.style = {rectangle, draw, text width = 2in, minimum height=1in}}
\begin{tikzpicture}[auto, font={\scriptsize}]
    % Place nodes
    \node [dataset] (tm) {Data 1 
                            \begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt]   %% this added.
                                \item{\# Adults } 
                                \item{\# Children} 
                                \item{Income}
                                \item{Ethnicity}
                            \end{itemize}\par};
    \node [dataset, right of=tm, node distance=3in] (dmv) {Data 2 
                            \begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt] 
                                \item{Data 2} 
                            \end{itemize}\par};
    % draw links
    \path [<->] (tm) edge node[above, sloped] {Address} (dmv);
\end{tikzpicture}
    \caption{Analysis dataset assembly.}
    \label{fig:dataset}
\end{figure}
\kant[2]

\end{document} 

在此处输入图片描述

相关内容