3

I'm trying to create a custom bullet for beamer using TikZ but for some reason it comes out improperly aligned (in particularly the bullet is slightly higher then the center of the text). How do I fix this?

Minimal example:

\documentclass[]{beamer}
\setbeamertemplate{itemize items}{\tikz\node[] {\tikz\draw[black,fill=gray] (0,0) circle (0.1);};}
\usepackage{tikz}
\begin{document}
\begin{frame} 
\frametitle{test}
\begin{itemize} 
\item Align this properly
\end{itemize}
\end{frame}
\end{document}

This outputs, enter image description here

(Notice the vertical position of the bullet compared to the text)

2 Answers 2

3

You can adjust the baseline. I have also modified the code for drawing the bullet.

\documentclass[]{beamer}
\setbeamertemplate{itemize items}{\tikz[baseline={(a.south)}]\node[draw,circle,black,fill=gray,inner sep=0pt,minimum size=2mm] (a){};}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{test}
\begin{itemize}
\item Align this properly
\end{itemize}
\end{frame}
\end{document}

enter image description here

2
  • Awesome thanks! Is there a reason to use \node instead of \draw? I like the infinite freedom of \draw.
    – JeffDror
    Commented Oct 5, 2015 at 16:12
  • @JeffDror: A node has anchor which can be used to align while draw doesn't. :)
    – user11232
    Commented Oct 5, 2015 at 16:15
3

Simply don't nest tikzpictures (as a general rule this should always be avoided) and you can keep all the \draw freedom:

\documentclass[]{beamer}
\setbeamertemplate{itemize items}{\tikz\draw[black,fill=gray] (0,0) circle (0.1);}
\usepackage{tikz}
\begin{document}
\begin{frame} 
\frametitle{test}
\begin{itemize} 
\item Align this properly
\end{itemize}
\end{frame}
\end{document}

enter image description here

A zoomed-in image:

enter image description here

What was the problem with the original code?

A TikZ \node has a non-zero inner sep and a non-zero outer sep whcih were adding additional spacing; you could have suppressed those by using

\setbeamertemplate{itemize items}{\tikz\node[inner sep=0pt,outer sep=0pt] {\tikz\draw[black,fill=gray] (0,0) circle (0.1);};}

but, as I mentioned before, the best approach is simply not to nest the tikzpictures.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .