
Ich habe dieses Bild gezeichnet, aber nicht so
\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}
Antwort1
Ich schätze, die Frage ist, wie man das effizienter oder besser zeichnen kann. Das Bild besteht eigentlich nur aus zwei Dreiecken mit etwas Text darüber. Um die Anpassung zu erleichtern, habe ich Koordinaten und für die Eckpunkte des Dreiecks definiert (A)
, (B)
beginnend (C)
von oben und im Uhrzeigersinn, und dann alles relativ zu diesen Koordinaten gezeichnet.
Der Text in den Kästchen auf den Dreiecken erscheint innerhalb der Schleife als kommagetrennte Liste \foreach
. Hier ist die Ausgabe:
...und hier ist der Code:
\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}
Die folgenden beiden Schummelfaktoren müssen möglicherweise feinabgestimmt werden:
- Die Textfelder haben einen Versatz von
(-0.3,-0.42)
, da die Quadratwurzel aus 2 mal 0,3 etwa 0,42 beträgt - die Mindestbreite des Textfelds Nummer
\c
ist eingestellt auf\c*26mm
Schließlich kann die Anzahl der Textfelder durch Ersetzen \c/5
in der Zeile
\foreach \word [count=\c, evaluate=c as \y using \c/5,]
zu \c/6
usw. Um dies richtig zu machen, müssen Sie wahrscheinlich die Koordinaten (A)
, (B)
und anpassen (C)
. Natürlich könnte dies im Prinzip auch automatisiert werden.
BEARBEITEN
Hier ist sgmoyes Zentrierungsverbesserung aus den Kommentaren. Ich habe den Breiten-„Offset“ des Knotens geändert auf \c*25mm
:
und das modifizierte 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}