
제가 이 그림을 그렸는데 이렇진 않네요
\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}