Graphics Scripts in Tex with TikZ and PGF
=========================================
I'm editing a presentation about drawing a regular heptadecagon with a
compass and a straightedge. Of course I want to draw shapes in my
documents. Fortunately, packages exists that allow you to draw them
and you don't need a floating OLE(Object Linking and Embedding) object like
in LibreOffice. In Wikibooks, you can find a pretty good tutorial[1] on TeX
and LaTex. Chapter 7 of the book is about creating graphics. If you want
really good stuff don't use the first thinf you see. Section 4 PGF/TikZ
is for professionals, and it allows the editor of a document to write a
script inside a markup doucument written in an "ancient" matkup language.
The package to use is named "tikz", and you add it using
usepackage{tikz}
Then you can define nodes and coordinates and draw lines and arcs.
More details about the package and libraries can be found at
https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ
If you want to learn even more about TikZ/PGF including about writing scrips,
you can scroll to the bottom of the page, and find the link
https://tikz.dev
One useful library I use is called "tikzmath". I have added it using the
directive
\usetikzlibrary[math]
To learn about it, choose Libraries from the left sidebar. then choose
Math Library. You will find there[2] a programing language with loops and
"if" statements and trigonometric functions and more...
Following is a little sample from my document:
\begin{tikzpicture}
\tikzmath{
\radius=6;
\xCoord=\radius * cos(360/17);
\yCoord=\radius * sin(360/17);
\orgX=0;
\orgY=0;
}
\coordinate (org) at (\orgX,\orgY);
\node (O) at (\orgX-0.1,\orgY){O};
\coordinate (pointA) at (\radius,0);
\node (A) at (\radius+0.1,0){A};
\coordinate (pointB) at (360/17:\radius);
\node(B) at (\xCoord,\yCoord+0.1){B};
\draw (org) -- (pointA);
\draw (pointA) arc (0:360/17:\radius);
\draw (pointB) -- (org);
\draw [very thick] (pointA) -- (pointB);
\draw (pointB) -- (\xCoord, 0);
\node (C) at (\xCoord, -0.14){C};
\end{tikzpicture}
[1]
https://en.wikibooks.org/wiki/LaTeX
[2]
https://tikz.dev/library-math