1

How would I generate a triangle like the one in the image below:

enter image description here

Also, how can I reduce the number of triangles inside as well as increase the number inside?

I have conducted numerous searches on the site but all I have come across is Sierpiński triangle's which are somewhat what I want but not exactly.(See image for reference).

Bumblebee
  • 255

2 Answers2

2

Instead of drawing inner triangles, just draw lines equally spaced along the three lines of the original triangle. The syntax for the point that is <pct> from node (a) to node (b) uses the calc library: ($ (a) !<pct>! (b) $). By putting <pct> into a \foreach loop, you can draw all the internal triangles.

This can be put into a macro so that \tritri{3}\qquad\tritri{6}\qquad\tritri{8} produces:

enter image description here

I added an optional argument to change the size. Default has the triangle inscribed in a circle of radius 1cm.

\tritri{3}\tritri[2]{3}

enter image description here

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{calc}

\newcommand{\tritri}[2][1]{\begin{tikzpicture} \draw(90:#1)node(a){}--(210:#1)node(b){}--(330:#1)node(c){}--cycle; \foreach \t[evaluate=\t as \r using (\t-1)/#2] in {2,...,#2}{ \draw($ (a) !\r! (b) $)--($ (a) !\r! (c) $); \draw($ (a) !\r! (c) $)--($ (b) !\r! (c) $); \draw($ (b) !\r! (c) $)--($ (b) !\r! (a) $); } \end{tikzpicture}}

\begin{document}

\tritri{3}\qquad\tritri{6}\qquad\tritri{8}

\end{document}

Sandy G
  • 42,558
1

I think you can try similar procedure like

How to draw figures in latex.

For prototypical purpose, I made an example latex code using tikz helper site:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\title{test} \author{pentagon}

\begin{document} \maketitle

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require: \path (0,278); %set diagram left start at 0, and has height of 278

%Shape: Triangle [id:dp09631185098075057] \draw (179.5,49) -- (282,225.16) -- (77,225.16) -- cycle ; %Shape: Triangle [id:dp13133055426437013] \draw (179.5,224.61) -- (128,139.08) -- (231,139.08) -- cycle ; %Shape: Triangle [id:dp001433677293123603] \draw (179.78,109.33) -- (161.57,80.61) -- (198,80.61) -- cycle ; %Shape: Triangle [id:dp6685327837402839] \draw (163.07,138.04) -- (146,109.33) -- (180.14,109.33) -- cycle ; %Shape: Triangle [id:dp34409029718729367] \draw (197.07,138.04) -- (180.14,109.33) -- (214,109.33) -- cycle ; %Shape: Triangle [id:dp23743278322396422] \draw (128.5,196.33) -- (111.75,167.61) -- (145.25,167.61) -- cycle ; %Shape: Triangle [id:dp7667441724383255] \draw (111.75,225.04) -- (95,196.33) -- (128.5,196.33) -- cycle ; %Shape: Triangle [id:dp605210826932941] \draw (145.25,225.04) -- (128.5,196.33) -- (162,196.33) -- cycle ; %Shape: Triangle [id:dp41616631919835156] \draw (231.5,196.33) -- (214.75,167.61) -- (248.25,167.61) -- cycle ; %Shape: Triangle [id:dp2871078395494677] \draw (214.75,225.04) -- (198,196.33) -- (231.5,196.33) -- cycle ; %Shape: Triangle [id:dp9503992575833584] \draw (248.25,225.04) -- (231.5,196.33) -- (265,196.33) -- cycle ; %Shape: Triangle [id:dp582528994709189] \draw (180.3,167.22) -- (198,196.33) -- (162,196.33) -- cycle ; %Shape: Triangle [id:dp3999733874796747] \draw (196.82,138.72) -- (213.75,167.61) -- (179.5,167.37) -- cycle ; %Shape: Triangle [id:dp030508632093482424] \draw (163.45,138.5) -- (180.5,167.33) -- (146,167.09) -- cycle ;

\end{tikzpicture}

\end{document}

and you can get this kind of code through the pale green colored botton. how to get tikz code

and the resulting pdf looks like this.

resulting pdf

Sorry for not being sophisticated but in my thought this tool is flexible and strong for the beginners. For the other number of triangles you can also adjust the figure by drag, drop, adding a new triangle, copy and paste the triangle, resizing them, and so on. I hope my answer helps you :)

eskim
  • 21