我画过这幅画,但不是这样的
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usepackage{xepersian}
\settextfont{Yas}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
%\definecolor{qqqqff}{rgb}{0.,0.,1.}
%\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
% \definecolor{myaqua}{rgb}{1,1,1}
\definecolor{qqqqff}{HTML}{21bdbe}
\definecolor{zzttqq}{HTML}{19bfe0}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(3.2557266494472623,-1.6520962393119207) rectangle (12.29163742054479,5.813639873201507);
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (3.6,-1.2) -- (11.6,-1.2) -- (8.,5.8) -- cycle;
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (7.2,3.6) -- (7.2,4.4) -- (11.6,4.4) -- (11.6,3.6) -- cycle;
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (7.,3.) -- (7.,2.2) -- (11.6,2.2) -- (11.584597952190476,2.9736025163350672) -- cycle;
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (11.6,1.6) -- (11.6,0.8) -- (6.8,0.8) -- (6.8,1.6) -- cycle;
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (11.6,0.2) -- (11.6,-0.6) -- (6.6,-0.6) -- (6.6,0.2) -- cycle;
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (7.972370141039504,5.756043406199211) -- (7.832933908904861,-1.2) -- (11.6,-1.2) -- cycle;
\draw [color=zzttqq] (3.6,-1.2)-- (11.6,-1.2);
\draw [color=zzttqq] (11.6,-1.2)-- (8.,5.8);
\draw [color=zzttqq] (8.,5.8)-- (3.6,-1.2);
\draw [color=zzttqq,line width=3pt] (7.2,3.6)-- (7.2,4.4);
\draw [color=zzttqq,line width=3pt] (7.2,4.4)-- (11.6,4.4);
\draw [color=zzttqq,line width=3pt] (11.6,4.4)-- (11.6,3.6);
\draw [color=zzttqq,line width=3pt] (11.6,3.6)-- (7.2,3.6);
\draw [color=zzttqq,line width=3pt] (7.,3.)-- (7.,2.2);
\draw [color=zzttqq,line width=3pt] (7.,2.2)-- (11.6,2.2);
\draw [color=zzttqq,line width=3pt] (11.6,2.2)-- (11.584597952190476,2.9736025163350672);
\draw [color=zzttqq,line width=3pt] (11.584597952190476,2.9736025163350672)-- (7.,3.);
\draw [color=zzttqq,line width=3pt] (11.6,1.6)-- (11.6,0.8);
\draw [color=zzttqq,line width=3pt] (11.6,0.8)-- (6.8,0.8);
\draw [color=zzttqq,line width=3pt] (6.8,0.8)-- (6.8,1.6);
\draw [color=zzttqq,line width=3pt] (6.8,1.6)-- (11.6,1.6);
\draw [color=zzttqq,line width=3pt] (11.6,0.2)-- (11.6,-0.6);
\draw [color=zzttqq,line width=3pt] (11.6,-0.6)-- (6.6,-0.6);
\draw [color=zzttqq,line width=3pt] (6.6,-0.6)-- (6.6,0.2);
\draw [color=zzttqq,line width=3pt] (6.6,0.2)-- (11.6,0.2);
\draw(9.566051220738322,4.243465214617333) node[anchor=north west] {hi};
\draw (-0.003126415538731179,0.18471185186201763) node[anchor=north west] {test};
\draw (9.343856693580186,2.8658591462368794) node[anchor=north west] {test};
\draw (9.180914040330887,1.354936361561543) node[anchor=north west] {test};
\draw (8.766150922969032,-0.12636048615937515) node[anchor=north west] {test};
\end{tikzpicture}
\end{document}
答案1
我猜问题是如何更高效或更好地绘制它。图片实际上只是两个三角形,顶部散布着一些文字。为了使其更容易定制,我定义了坐标(A)
,(B)
以及(C)
三角形顶点,从顶部开始顺时针读取,然后绘制相对于这些坐标的所有内容。
三角形框中的文本在循环内显示为逗号分隔的列表\foreach
。输出如下:
...代码如下:
\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\definecolor{leftcolour}{HTML}{21bdbe}
\definecolor{rightcolour}{HTML}{19bfe0}
\begin{document}
\begin{tikzpicture}[
nodetext/.style={draw=leftcolour, very thick, rectangle, anchor=south west,
fill=white,minimum height=2em},
lefttriangle/.style={draw=leftcolour,fill=leftcolour},
righttriangle/.style={draw=rightcolour,fill=rightcolour!50}
]
\coordinate (A) at (0,8.5); % top - formerly (8,5.8);
\coordinate (B) at (6,0); % bottom right - formerly(11.6, -1.2);
\coordinate (C) at (-6,0); % bottom left - (3.6,-1.2);
\draw[lefttriangle] (A) -- ($ (C)!0.5!(B) $) --(C) -- cycle;
\draw[righttriangle] (A) -- ($ (C)!0.5!(B) $) --(B) -- cycle;
\foreach \word [count=\c, evaluate=c as \y using \c/5,]
in {Test 1, Test 2, Test 3, Test 4} {
\node[nodetext, minimum width=\c*26mm] at ($ (A)!\y!(C)+(-0.3,-0.42) $){\word};
}
\end{tikzpicture}
\end{document}
以下两个模糊因素可能需要进行微调:
- 文本框的偏移量为
(-0.3,-0.42)
,因为 2 乘以 0.3 的平方根约为 0.42 - 文本框的最小宽度
\c
设置为\c*26mm
\c/5
最后,可以通过替换以下行来更改文本框的数量
\foreach \word [count=\c, evaluate=c as \y using \c/5,]
等\c/6
。当然,要正确执行此操作,您可能需要调整坐标(A)
,(B)
和(C)
。当然,原则上,这也可以自动化。
编辑
以下是来自评论的 sgmoye 居中改进。我已将节点的宽度“偏移”更改为\c*25mm
:
以及修改后的 MWE:
\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\definecolor{leftcolour}{HTML}{21bdbe}
\definecolor{rightcolour}{HTML}{19bfe0}
\begin{document}
\begin{tikzpicture}[
nodetext/.style={draw=leftcolour, very thick, rectangle, anchor=south,
fill=white,minimum height=2em},
lefttriangle/.style={draw=leftcolour,fill=leftcolour},
righttriangle/.style={draw=rightcolour,fill=rightcolour!50}
]
\coordinate (A) at (0,8.5); % top - formerly (8,5.8);
\coordinate (B) at (6,0); % bottom right - formerly(11.6, -1.2);
\coordinate (C) at (-6,0); % bottom left - (3.6,-1.2);
\draw[lefttriangle] (A) -- ($ (C)!0.5!(B) $) --(C) -- cycle;
\draw[righttriangle] (A) -- ($ (C)!0.5!(B) $) --(B) -- cycle;
\foreach \word [count=\c] in {Test 1, Test 2, Test 3, Test 4} {
\node[nodetext, minimum width=\c*25mm] at (0, 8.5-1.85*\c){\word};
}
\end{tikzpicture}
\end{document}