![tikz 环境中的项目符号列表](https://linux22.com/image/414517/tikz%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E9%A1%B9%E7%9B%AE%E7%AC%A6%E5%8F%B7%E5%88%97%E8%A1%A8.png)
我正在与蒂克兹具有以下特征的图形制作环境。
1)带有图形标题的圆角矩形
2)分为两部分,带有副标题
3)每个部分都有几个带有文字的小圆框。所有框的单侧都相同。但左侧的矩形小于右侧的矩形(需要两种样式,我只做了一种样式,我不知道如何在一个图中制作两种样式)
4)在框之后,需要大花括号(覆盖所有框),并且在花括号旁边,两侧都需要一个项目符号列表(当我制作这个项目符号列表时,出现了很多错误,所以我从代码中删除了这部分)。
5)左侧的框需要右对齐,右侧的框需要左对齐(在我的工作中,两者都是居中对齐,如果我们为每个框制作两种单独的样式,可能会很简单)。
6)项目符号列表必须为菱形。左侧花括号为闭括号,项目符号列表在此右。右侧花括号为开括号类型,项目符号列表在此左。两个项目符号列表均左对齐。
提前致谢。
\usepackage{graphicx, sectsty, etoolbox}%
\usepackage{geometry}
\geometry{margin=1.25cm, twocolumn}
\usepackage{multicol}
\usepackage{caption}
\usepackage{tikz}
\usepackage{multirow}
\usepackage{color, colortbl}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{lipsum}
\renewcommand\theadfont{\small\bfseries}
%\usepackage{authblk}
\title{A figure document}
\usepackage{lipsum}
\begin{document}
\section{Section: tikzpicture}
\lipsum[2-5]
\begin{figure}[b]
\centering
\begin{tikzpicture}[
myrectangle/.style={rectangle, draw, minimum width=65, minimum height=3, rounded corners=2, blue, text=black , text align=left, fill=blue!5}
]
\node[rectangle, draw, minimum width=268, minimum height=140, rounded corners=5, blue, thick, text height= -15cm] at (0,0);
\node [blue, thick] at (0,2.1){\scriptsize Head line of the figure};% figure head
\node [red, thick] at (-2.7,1.25){\scriptsize Sub head1};% sub head
%curly brackets
\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt},yshift=0pt]
(-2.3,-1.7) -- (-2.3,1.05) node [black,midway] ;
\draw [decorate,decoration={brace,amplitude=10pt},xshift=-4pt,yshift=0pt]
(2.3,-2.4) -- (2.3,1) node [black,midway];
\node [red, thick] at (1.7,1.25){\scriptsize Sub head2};
% need a diamond-shaped bullet list
\draw [blue, thick] (-4.7,1.7) -- (4.7,1.7);
\draw [blue, thick] (-1.2,1.7) -- (-1.2,-2.5);
%------------------------------left side box
\node[myrectangle] (a) at (-3.3,.80) {\scriptsize text1};
\node[myrectangle, below=0.02 of a] (b) {\scriptsize text2};
\node[myrectangle, below=0.02 of b] (c) {\scriptsize text3};
\node[myrectangle, below=0.02 of c] (d) {\scriptsize text4};
\node[myrectangle, below=0.02 of d] (e) {\scriptsize text5};
\node[myrectangle, below=0.02 of e] (f) {\scriptsize text6};
%------------------------------ right side box
\node[myrectangle] (a) at (3.3,.8) {\scriptsize text7};
\node[myrectangle, below=0.02 of a] (b) {\scriptsize text8};
\node[myrectangle, below=0.02 of b] (c) {\scriptsize text9};
\node[myrectangle, below=0.02 of c] (d) {\scriptsize text10};
\node[myrectangle, below=0.02 of d] (e) {\scriptsize text11};
\node[myrectangle, below=0.02 of e] (f) {\scriptsize text12};
\node[myrectangle, below=0.02 of f] (g) {\scriptsize text13};
\node[myrectangle, below=0.02 of g] (h) {\scriptsize text14};
\end{tikzpicture}
\caption{A figure containing two types of data}
\label{EHR}
\end{figure}
\lipsum[5-8]
\end{document}
答案1
下面的代码展示了一种实现此目的的可能性。代码中有一些注释,如果其中有任何部分需要进一步解释,请询问。
\documentclass[border=5mm]{standalone}
% for \blacklozenge
\usepackage{amssymb}
% the enumitem package is used for customizing lists
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{
fit,
positioning,
chains,
decorations.pathreplacing
}
% define a new list type based on itemize
\newlist{diagramlist}{itemize}{1}
\setlist[diagramlist,1]{%
nosep, % reduce whitespace in list
label=$\blacklozenge$, % set the type of bullet point
left=0pt % reduce the space on the left side
}
\begin{document}
\begin{tikzpicture}[
% this defines the gap between the small boxes
node distance=0.2mm,
% this defines the width of the box containing the lists
declare function={listW=2cm;},
% common styles for the two rectangle types
baserect/.style={
draw,
rounded corners=2,
blue,
text=black,
fill=blue!5,
font=\scriptsize
},
% make styles for left and right rectangles, with
% different text widths and alignments, based on the baserect style defined above
% change the text widths to whatever to find appropriate
leftrect/.style={baserect, text width=3cm, align=right},
rightrect/.style={baserect, text width=4cm, align=left},
% make a style for the nodes containing the lists
listnode/.style={
midway,
text width=listW,
font=\scriptsize
},
% make a style for the nodes containing the titles
titlenode/.style={
red,
font=\scriptsize,
above=1.5mm
}
]
% local bounding box=left will make node called left which fits
% around the content in the scope environment
\begin{scope}[local bounding box=left]
% a chain is a way of automatically placing nodes
% "l going below" means the chain is called l and runs downward
\begin{scope}[
start chain=l going below,
every node/.append style={leftrect, on chain}
]
\node {text 1};
\node {text 2};
\node {text 3};
\node {text 4};
\node {text 5};
\node {text 6};
\end{scope}
% then draw the brace. the first and last node in the chain are automatically
% named l-begin and l-end
\draw [
decorate,
decoration={brace,amplitude=10pt,raise=4pt}
]
(l-begin.north east) -- (l-end.south east)
node[listnode, right=15pt] (leftlist) {%
\begin{diagramlist}
\item foo
\item bar
\item baz
\end{diagramlist}
};
\end{scope}
\begin{scope}[local bounding box=right]
\begin{scope}[
start chain=r going below,
every node/.append style={rightrect, on chain}
]
% place first node at the same height as the first node in the left part
% at a distance right of the node for the left list
% the distance is 1cm more than the text width of the list nodes
\node [right=listW + 1cm of l-1.east-|leftlist.east] {text 1};
\node {text 2};
\node {text 3};
\node {text 4};
\node {text 5};
\node {text 6};
\node {text 7};
\node {text 8};
\end{scope}
\draw [
decorate,
decoration={brace,amplitude=10pt,mirror,raise=4pt}
]
(r-begin.north west) -- (r-end.south west)
node[listnode, left=15pt] (rightlist) {%
\begin{diagramlist}
\item foo2
\item bar2
\item baz2
\end{diagramlist}
};
\end{scope}
% titles for subparts
\node [titlenode] (sub1) at (left.north) {Sub head 1};
\node [titlenode] (sub2) at (right.north) {Sub head 2};
% title for the whole thing
\node [titlenode, blue, inner ysep=2mm] (head) at (current bounding box.north) {Headline of figure};
% use the fit library to draw the frame around the whole thing
\node [baserect, fill=none, fit=(current bounding box)] (frame) {};
% first define a coordinate midway between the two list nodes
\path (leftlist.east) -- coordinate (mid) (leftlist.east -| rightlist.west);
% then draw the dividers
\draw [blue] (frame.west |- head.south) -- (frame.east |- head.south);
\draw [blue] (mid |- frame.south) -- (mid |- head.south);
\end{tikzpicture}
\end{document}