3

I created a polygon using tikz package. I need to change the background color for my text to match with the background color of the slide. I'm attaching the photo.enter image description here

\begin{figure} [H]
\begin{center}
\begin{tikzpicture} [scale=0.4]
\tikzstyle{every node}=[draw,circle,fill=white,minimum size=1pt,
                    inner sep=0pt]
\draw  node (1) [label=$v_{1,1}$] {}
-- ++(330:2.0cm) node [](2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(210:2.0cm) node (4)
[] {}-- ++(150:2.0cm) node (5)
[] {}-- ++(90:2.0cm) node (6)
[] {}-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path (4) edge (5);
\path (5) edge (6);
\path [](6) edge (1);

\draw (4) node[below,xshift=0mm,draw=white]{Layer 1};
\draw (1) node[below,yshift=-5mm,draw=white]{$K_n$};

\end{tikzpicture}
\end{center}
\caption{$K_n \square P_3$} 
\label{3}
\end{figure}
4

The background colour can be used under the name bg:

\documentclass{beamer}
\usepackage{tikz}

\setbeamercolor{background canvas}{bg=orange!50!white}

\begin{document}

\begin{frame}
\begin{tikzpicture} [scale=0.4]
\usebeamercolor{background canvas}
\tikzstyle{every node}=[draw,minimum size=1pt,
                    inner sep=0pt]
\draw  node (1) [label=$v_{1,1}$] {}
-- ++(330:2.0cm) node [](2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(210:2.0cm) node (4)
[] {}-- ++(150:2.0cm) node (5)
[] {}-- ++(90:2.0cm) node (6)
[] {}-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path (4) edge (5);
\path (5) edge (6);
\path [](6) edge (1);

\draw (4) node[below,xshift=0mm,draw=bg]{Layer 1};
\draw (1) node[below,yshift=-5mm,draw=bg]{$K_n$};

\end{tikzpicture}
\end{frame} 

\end{document}

enter image description here

2

Better than filling these nodes with a solid color which matches the background color, is not to fill the nodes. This way, if the background color changes, the code is still correct.

To do so you only have to remove the fill=white and draw=white options for those nodes. This way, no filling nor drawing takes place.

To have little dots at the vertices of hexagon, you can use every node/.style in a scope. Also, do not use \draw for the hexagon, but \path, since the edges are drawn later.

This is my suggested code:

\documentclass{beamer}
\usepackage{tikz}
\setbeamercolor{background canvas}{bg=orange!50!white}

\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[scale=0.4]
\begin{scope}[every node/.style={circle,minimum size=2pt,
             inner sep=0pt, fill}]
  \path  node (1) [label=$v_{1,1}$] {}
  -- ++(330:2.0cm) node [](2) [] {}
  -- ++(270:2.0cm) node (3)
  [] {}-- ++(210:2.0cm) node (4)
  [] {}-- ++(150:2.0cm) node (5)
  [] {}-- ++(90:2.0cm) node (6)
  [] {}-- ++(30:2.0cm) node (1)
  {};
\end{scope}

\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed] (3) edge (4);
\path (4) edge (5);
\path (5) edge (6);
\path [](6) edge (1);
\draw (4) node[below,xshift=0mm,]{Layer 1};
\draw (1) node[below,yshift=-5mm]{$K_n$};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

Result

Update. Not related with your question but leveraging the opportunity, your code can be refactorized to use a loop and custom styles, to make it shorter and (imho) more readable:

\documentclass{beamer}
\usepackage{tikz}
\setbeamercolor{background canvas}{bg=orange!50!white}

\begin{document}
\begin{frame}
\begin{center}
\tikzset{
  smalldot/.style={circle,minimum size=2pt, inner sep=0pt, fill}
  }
\begin{tikzpicture}[scale=0.4]
  \foreach \angle [count=\n from 1] in {30, 90, ..., 330}
      \node[smalldot] (\n) at (\angle:2cm) {};
  \draw (6) -- (1) -- (2) -- (3) -- (4) -- (5);
  \draw [dashed] (5) -- (6);
  \node[above] at (2) {$v_{1,1}$};
  \node[below] at (5) {Layer 1};
  \node at (0,0) {$K_n$};
\end{tikzpicture}
\end{center}
\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.