1

I have the following example:

\documentclass[]{beamer}
\usetheme{Darmstadt}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
    \begin{frame}{}
        \begin{tikzpicture}[>=latex]
        \tikzstyle{vertex} = [circle, fill=black!10]
        \tikzstyle{selected vertex} = [circle, radius=0.1cm, fill=red!30]
        \tikzstyle{nedge} = [-]

        \node[vertex] (v1) at (3,0) {v1};
        \node[vertex] (v2) at (0,-1) {v2};
        \node[vertex] (v3) at (6,-1) {v3};
        \draw[nedge] (v1) -- (v2);
        \draw[nedge] (v1) -- (v3);
    \end{tikzpicture}
\end{frame}
\end{document}

I want to change the radius of vertice in tikz style. How to do it? Thanks for the help.

5
  • 3
    Node size can be set with minimum width=2cm Sep 22 at 4:26
  • Or minimum radius=2cm? (Did not check)
    – Symbol 1
    Sep 22 at 5:41
  • minimum size should also work, but if you want an exact size you may also need to adjust inner offset (not sure) Sep 22 at 5:46
  • 1
    @AndrewStacey inner sep
    – gernot
    Sep 22 at 8:38
  • TikZ nodes expand to fit the contents, hence the minimum in minimum size. Setting [inner sep=0pt] will help avoid filling the space. Setting [inner sep=-1cm] would help even more. Sep 22 at 13:28
2

First, don't use tikzstyle which is deprecated, but use tikzset instead. Then, define your nodes as circle with inner sep=0pt (you can also set the outer sep to 0pt), and with a minimum width which is your node diameter.

Finally, you can make other node style inherit a previous one like I did. The selected vertex inherits all parameters from the vertex style, and you can add/replace some afterwards (like the filling here).

circle node tikzset

\documentclass[]{beamer}
\usetheme{Darmstadt}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
    \begin{frame}{}
        \begin{tikzpicture}[>=latex]
        \tikzset
            {
            vertex/.style={circle, inner sep=0pt, outer sep=0pt, minimum width=1cm,fill=black!10},
            selected vertex/.style = {vertex, fill=red!30},
            nedge/.style = {-}
            }

        \node[vertex] (v1) at (3,0) {v1};
        \node[vertex] (v2) at (0,-1) {v2};
        \node[vertex] (v3) at (6,-1) {v3};
        \draw[nedge] (v1) -- (v2);
        \draw[nedge] (v1) -- (v3);
    \end{tikzpicture}
\end{frame}
\end{document}

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.