使用以下代码这个帖子,是否可以修改代码以在不同的面内插入文本?
还可以控制折叠和切割线的形状吗?
\documentclass{article}
\usepackage{tikz,xparse}
\usetikzlibrary{folding,calc}
\begin{document}
\tikzset{%
patron/.style={%
line join=round, rounded corners=.05pt, draw, thin},
patron side/.style={patron},
patron languette/.style={patron},
}
\newcounter{NodePat}
\NewDocumentCommand{\PolygReg}{%
O{3}
m
O{A}
}
{%
\foreach \a/\b in {#2}
{%
\path[patron side] let
\p1 = ($(\a)!.5!(\b)$) ,
\n1 = {veclen(\x1,\y1)} ,
\p2 = ($(\p1)!1/tan(180/#1)!90:(\b)$)
in
(\a)--(\b)
\foreach \i [%
evaluate=\i as \j using (\i-1)*360/#1] in {3,...,#1} {%
-- ($(\p2)!1!\j:(\a)$) coordinate (#3\theNodePat)
\pgfextra{\stepcounter{NodePat}}
}
-- cycle ;}}
\NewDocumentCommand{\Languette}{%
O{.15}
D<>{45}
m
D<>{45}
O{A}
}
{%
\foreach \b/\a in {#3} {%
\path[patron languette] let
\p1 = ($(#5\b)!#1/sin(#2)!-#2:(#5\a)$),
\p2 = ($(#5\a)!#1/sin(#4)!#4:(#5\b)$)
in
(#5\a) -- (#5\b) -- (\p1) -- (\p2) -- cycle ; }
}
\makeatletter
\newcommand{\AffNodesPatron}[1][A]{%
\newcount\X
\X=1
\loop
\expandafter\ifx\csname pgf@sh@pi@A\the\X\endcsname\pgfpictureid
\node[font={\footnotesize},red] at (A\the\X) {A\the\X} ;
\advance \X by 1
\else
\X=0
\fi
\unless\ifnum \X=0
\repeat
}
\makeatother
\begin{tikzpicture}[scale=3]
\coordinate (A1) at (0,0) ;
\coordinate (A2) at (0,-1) ;
\setcounter{NodePat}{3}
\PolygReg{A1/A2,A1/A3,A3/A2,A5/A2}
\Languette{3/4,6/5,2/6}
\AffNodesPatron
\end{tikzpicture}
\end{document}
答案1
如果我理解你的问题,你只需要\node
在需要每个文本的地方放置 s。例如,第二个图的代码可以是以下内容:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2,line join=round,line cap=round]
\foreach\xi in {1,2,3}
{%
\begin{scope}[shift={(120*\xi-90:1)},rotate=120*\xi-180]
\draw[green,dashed] (90:1) -- (-30:1) -- (210:1);
\draw[blue] (210:1) -- (90:1) -- (30:0.8) -- (-30:1);
\end{scope}
}
\node[red,fill=yellow] at (0,0) {1};
\node[magenta,rotate=-60] at (30:1) {2};
\node[green,rotate=60] at (150:1) {\huge 4};
\node[green,rotate=180] at (270:1) {\bfseries 3};
\end{tikzpicture}
\end{document}
其结果为:
现在看看代码的最后几行。
\node[red,fill=yellow] at (0,0) {1};
将在该点绘制一个节点(0,0)
,其中文本1
为红色,填充为黄色,依此类推。
PS. 我为这个绘图写了一个简短的代码,但它在你发布的代码中是相同的。你只需要将坐标调整到所需的位置即可。