TransWikia.com

Inserting text in a polyhedral folding drawing

TeX - LaTeX Asked on July 10, 2021

Using the following code from this post,
is it possible to modify the code to insert text inside different faces?

Also is it possible to control the shape of the folding and cutting lines?

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 (#3theNodePat)
  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 = ($(#5b)!#1/sin(#2)!-#2:(#5a)$),
p2 = ($(#5a)!#1/sin(#4)!#4:(#5b)$)
in
(#5a) -- (#5b) -- (p1) -- (p2) -- cycle ; }
}
makeatletter
newcommand{AffNodesPatron}[1][A]{%
 newcountX
 X=1
 loop
 expandafterifxcsname pgf@sh@pi@AtheXendcsnamepgfpictureid
 node[font={footnotesize},red] at (AtheX) {AtheX} ;
 advance X by 1
 else
 X=0
 fi
 unlessifnum 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}

enter image description here

enter image description here

One Answer

If I understand your question, you only need to put nodes where you need each text. For example, a code for your second figure could be the following:

documentclass[border=2mm]{standalone}
usepackage{tikz}

begin{document}
begin{tikzpicture}[scale=2,line join=round,line cap=round]
foreachxi 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}

Which produces:

enter image description here

Now look at the last lines of the code. The line

node[red,fill=yellow] at (0,0) {1};

will draw a node at the point (0,0) with the text 1 in red and with a yellow filling, and so on.

PS. I wrote a brief code for this drawing, but it will be the same in the code you posted. You only need to adjust the coordinates to the desired positions.

Answered by Juan Castaño on July 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP