Is there any good tutorial/approach in LaTeX for drawing polygons filled with color?
EDIT: I would like to use pdfLaTeX interpreter
Sure, you can use TikZ
for instance. There is a node shape regular polygon
, it can be used like this:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\foreach \a in {3,...,8}{
\node[regular polygon, regular polygon sides=\a, minimum size=2cm, anchor=south, fill=blue!40] at (\a*4,0) {};
}
\end{tikzpicture}
\end{document}
With the following result:
Note that you can determine the color by changing fill=blue!40
to any color definition you like. If you want to add a border to the polygon, you can use the draw
option on the node. You can change the color of that by using draw=color
. You don't need to use a node, you can of course contruct a regular polygon path, but a node is the easiest way to directly get a regular polygon.
standalone
class. You can just as easily use article
as the documentclass. I just used standalone
in order to get a nice pdf
to upload as an example.
Commented
Jan 30, 2012 at 14:43