Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any good tutorial/approach in LaTeX for drawing polygons filled with color?

EDIT: I would like to use pdfLaTeX interpreter

share|improve this question

1 Answer 1

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:

Regular polygons in TikZ

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.

share|improve this answer
    
Sorry I didn't mention - I would like to use pdfLaTeX interpreter. Now I see ! LaTeX Error: File `standalone.cls' not found. for you example. –  Michael Z Jan 30 '12 at 14:38
    
I have found solution by myself. I use \documentclass{article} instead of \documentclass{standalone} and it works! –  Michael Z Jan 30 '12 at 14:42
    
That just means you don't have the 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. –  Roelof Spijker Jan 30 '12 at 14:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.