0

I'm trying to get some information on how to plot graphs from this very interesting and nice open book (Discrete Mathematics: An Open Introduction, Oscar Levin) and its source code.

This is the code copied and pasted from the original (without configuration!):

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \coordinate (A) at (90+360/5:1);
    \coordinate (B) at (90+2*360/5:1);
    \coordinate (C) at (90+3*360/5:1);
    \coordinate (D) at (90+4*360/5:1);
    \coordinate (E) at (90:1);

    \draw (A) -- (B) -- (C) -- (D) -- (E) -- (A);
    \foreach \x in {(A), (B), (C), (D), (E)}{
        \fill \x \v;
    }
\end{tikzpicture}
\end{document}

And this what I get:

enter image description here

There should be some initialization to get the vertices bigger as in the linked book:

enter image description here

I would prefer a direct link to the lines of the linked source code (referring to the initialization file and to the file containing the copied lines), so that in the future I can refer directly there.

2

You do not define \v but I suspect it may be a macro for a circle. Nevertheless, things can be simplified.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{fancy ngon/.style={regular polygon,draw,minimum width=2cm,regular polygon sides=#1,alias=ngon,
append after command={foreach \XX in {1,...,#1} {(ngon.corner \XX) node[bullet]}}},
bullet/.style={circle,fill,inner sep=1.5pt,node contents={}}}
\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (90+360/5:1);
    \coordinate (B) at (90+2*360/5:1);
    \coordinate (C) at (90+3*360/5:1);
    \coordinate (D) at (90+4*360/5:1);
    \coordinate (E) at (90:1);

    \draw (A) -- (B) -- (C) -- (D) -- (E) -- (A);
    \foreach \x in {(A), (B), (C), (D), (E)}{
        \fill \x circle[radius=2pt];
    }
\end{tikzpicture}

\begin{tikzpicture}
    \node[fancy ngon=5]{};
    \node[fancy ngon=6] at (3,0) {};
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you. I thought that I destroyed the web page with my last click... – PeptideChain Jun 26 '19 at 20:04
  • How do you move [radius=2pt] into tikzset? bullet is a standard style that is overriden? could I define instead mybullet and in the pic reference to it? – PeptideChain Jun 27 '19 at 17:50
  • @PeptideChain Yes, or you could just use bullet/.style={circle,fill,inner sep=2pt,node contents={}} (where I replaced 1.5pt by 2pt). – user121799 Jun 27 '19 at 17:51
  • thank you, I understand – PeptideChain Jun 27 '19 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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