我有一个字符串,格式为,.[field].[field].[field]
其中每个都[field]
需要用用户特定信息替换。我想创建某种说明/指南,说明每个字段需要哪些特定信息。
我的想法(抱歉画得不好):
第一个例子:
第二个例子:
我不知道这是否是最好的方法,但我认为一些可视化将比一块文本更有助于用户理解(用户是普通人)。
我如何使用 TikZ 创建如上所示的图表?我一直在尝试使用node
s 和path
s,但由于我很少使用 TikZ,所以我没有取得很大进展。任何帮助都非常感谢!
编辑:
感谢 Gonzalo Medina 提供的两个示例。我对其进行了一些修改,这是我的最终结果:
\documentclass[dvipsnames]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\newcommand{\intval}[1]{\textbf{\color{RoyalBlue}#1}}
\tikzset
{ field/.style = { draw=RoyalBlue, minimum height=20pt }
, pdval/.style = { draw=black!10, font=\strut\LARGE
, minimum height=20pt, text depth=-2pt }
, dot/.style = { fill=black, circle, anchor=south
, inner sep=1.2pt, xshift=-5pt, yshift=3pt }
, desc/.style = { fill=black!10, rounded corners=5pt, inner sep=5pt }
, num/.style = { draw, circle }
}
\begin{document}
\begin{tikzpicture}[node distance=10pt, scale=.8, transform shape]
% fields
\node[field,text width=60pt] (user) {};
\node[field,right=of user,text width=30pt] (year) {};
\node[pdval,right=of year] (function) {st};
\node[field,right=of function,text width=20pt] (realm) {};
\node[pdval,right=of realm] (entity) {foo};
\node[pdval,right=of entity] (school) {bar};
% dots
\foreach \n in {user,year,function,realm,entity,school}
\node[dot] at (\n.south west) {};
% numbers & descriptions
\node[num,above=4cm of user.west,xshift=5pt] (user_num) {\textbf{1}};
\node[desc,right=5pt of user_num] ()
{Your \textbf{username}, f.e. \textit{foobar}};
\node[num,above=2cm of year.west,xshift=5pt] (year_num) {\textbf{2}};
\node[desc,above=5pt of year_num,xshift=7pt] ()
{Your \textbf{year of joining}, f.e. \textit{2012}};
\node[num,above=1.5cm of realm.west,xshift=5pt] (realm_num) {\textbf{3}};
\node[desc,right=5pt of realm_num,yshift=30pt,text width=5cm] ()
{
Your \textbf{realm}:\\[10pt]
\noindent
\begin{tabular}{@{}ll}
Architecture & \intval{A} \\
Constructional engineering & \intval{CE} \\
Chemistry & \intval{C} \\
Digital technology & \intval{DT} \\
Telecommunication & \intval{T} \\
\end{tabular}
};
% lines
\draw (user_num.south) -- ([xshift=5pt]user.north west);
\draw (year_num.south) -- ([xshift=5pt]year.north west);
\draw (realm_num.south) -- ([xshift=5pt]realm.north west);
\end{tikzpicture}
\end{document}
答案1
两种方案都适用的一个选项:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
descr/.style={
fill=gray!30,
text width=#1
},
field/.style={
draw,
text width=3cm,
minimum height=15pt
},
dot/.style={
fill=black,
circle,
inner sep=1.2pt
},
number/.style={
draw,
circle,
minimum size=20pt,
font=\Large
}
}
\begin{document}
\begin{tikzpicture}[node distance=1cm and 10pt]
% the field nodes
\node[field]
(left) {};
\node[field,right=of left]
(middle) {};
\node[field,right=of middle]
(right) {};
\node[right=10pt of right.south east,anchor=south west,inner sep=0pt,font=\LARGE]
(foo) {foo};
\node[right=10pt of foo.south east,anchor=south west,inner sep=0pt,font=\LARGE]
(bar) {bar};
% dots between the fields
\node[dot,xshift=-5pt,anchor=south]
at (left.south west) {};
\foreach \Nombre in {left,middle,right,foo}
{
\node[dot,xshift=5pt,anchor=south]
at (\Nombre.south east) {};
}
% the boxes for the descriptions
\node[descr=8cm,above=6cm of left,anchor=south west,xshift=10pt]
(lefttext)
{Some descriptive text for the first field and some more text and some more text and some more text};
\node[number,anchor=east]
(leftnumber)
at (lefttext.west) {1};
\node[descr=4.4cm,above=4cm of middle,anchor=south west,xshift=10pt]
(middletext)
{Some descriptive text for the first field and some more text and some more text and some more text};
\node[number,anchor=east]
(middlenumber)
at (middletext.west) {2};
\node[descr=4cm,above=2cm of right,anchor=south east,xshift=-5pt]
(righttext)
{Some descriptive text for the first field and some more text and some more text and some more text};
\node[number,anchor=west]
(rightnumber)
at (righttext.east) {3};
% the connecting lines
\foreach \Nombre in {left,middle}
\draw (\Nombre number.west) -| ([xshift=10pt]\Nombre.north west);
\draw (rightnumber.east) -| ([xshift=-10pt]right.north east);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[node distance=1cm and 10pt]
% the field nodes
\node[field]
(left) {};
\node[field,right=of left]
(middle) {};
\node[field,right=of middle]
(right) {};
\node[right=10pt of right.south east,anchor=south west,inner sep=0pt,font=\LARGE]
(foo) {foo};
\node[right=10pt of foo.south east,anchor=south west,inner sep=0pt,font=\LARGE]
(bar) {bar};
% dots between the fields
\node[dot,xshift=-5pt,anchor=south]
at (left.south west) {};
\foreach \Nombre in {left,middle,right,foo}
{
\node[dot,xshift=5pt,anchor=south]
at (\Nombre.south east) {};
}
% the boxes for the descriptions
\node[descr=8cm,above=6cm of left.west,anchor=south west]
(lefttext)
{Some descriptive text for the first field and some more text and some more text and some more text};
\node[descr=4.4cm,above=4cm of middle.west,anchor=south west]
(middletext)
{Some descriptive text for the first field and some more text and some more text and some more text};
\node[descr=4.4cm,above=2cm of right.west,anchor=south west]
(righttext)
{Some descriptive text for the first field and some more text and some more text and some more text};
% the connecting lines
\foreach \Nombre in {left,middle,right}
\draw ([xshift=10pt]\Nombre text.south west) -- ([xshift=10pt]\Nombre.north west);
\end{tikzpicture}
\end{document}