Graphics, Figures & TablesRegular Pentagon with labeled Vertices

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Richard_B
Posts: 4
Joined: Mon May 28, 2012 4:37 am

Regular Pentagon with labeled Vertices

Post by Richard_B »

I am trying to get a regular pentagon with vertices labeled 1, 2, 3, 4, 5. I was able to get a square with labeled vertices. The code is shown below. The pentagon seems more difficult. I am just learning the LaTeX picture environment, so I'd like to use that, if possible. But if it's easier using pstricks (which I know very little of, other than the name), that would be fine too.

Thank you.

Code: Select all

\documentclass{article}
\begin{document}
% a square with labeled vertices
\setlength{\unitlength}{3cm}
\begin{picture}(2,2)
\linethickness{0.3mm}
\put(0,0){\line(1,0){1}}
\put(0,0){\circle*{.05}}
\put(1,0){\circle*{.05}}
\put(1,1){\circle*{.05}}
\put(0,1){\circle*{.05}}
\put(0,0){\line(0,1){1}}
\put(1,0){\line(0,1){1}}
\put(0,1){\line(1,0){1}}
\put(-0.1,1.05){$1$}
\put(1,1.05){$2$}
\put(1.05,-0.05){$3$}
\put(-0.13,-0.05){$4$}
\end{picture}
\end{document}
Last edited by localghost on Sun Jun 24, 2012 8:36 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Regular Pentagon with labeled Vertices

Post by Stefan Kottwitz »

Hi Richard,

I would use tikZ. It provides a rich syntax and has great capabilities. A quick example for your pentagon:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \newdimen\R
  \R=0.8cm
  \draw (0:\R)
     \foreach \x in {72,144,...,360} {  -- (\x:\R) }
              -- cycle (360:\R) node[right] {5}
              -- cycle (288:\R) node[below right] {4}
              -- cycle (216:\R) node[below left] {3}
              -- cycle (144:\R) node[above left] {2}
              -- cycle  (72:\R) node[above right] {1};
\end{tikzpicture}
\end{document}
\foreach \x in {72,144,...,360} { -- (\x:\R) } is for the pentagon, the rest for the labels. It's derived from the hexagon for memorizing trigonometric identities by Josef Nilsen. You can find this and more Examples in the TikZ example gallery.

Stefan
LaTeX.org admin
jake
Posts: 3
Joined: Sat Jun 23, 2012 11:26 pm

Regular Pentagon with labeled Vertices

Post by jake »

Yup, I would also go with TikZ. You'll probably be happier learning TikZ than the picture environment syntax, as it's a lot more powerful.

Stefan's example can even be simplified a bit:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\newdimen\R
\R=0.8cm

\draw (0:\R)
\foreach [count=\n] \x in {72,144,...,360} {
	-- (\x:\R) node [anchor=180+\x] {\n}
};
\end{tikzpicture}
\end{document}
Richard_B
Posts: 4
Joined: Mon May 28, 2012 4:37 am

Re: Regular Pentagon with labeled Vertices

Post by Richard_B »

Fantastic! This tikZ stuff looks really great. I plan to go learn more about it now.

Thanks again!
-RB
Post Reply