17

I have an enumerate environment with square icons, which gives me a colored square with a number inside for each item.

Below this, I have things I would like to visually correspond with these items. So I am looking to just make this same square with a number inside. Any ideas?

Edit: Here is a minimal working example:

\documentclass[mathserif,xcolor=svgnames]{beamer}
\setbeamertemplate{enumerate items}[square]
\begin{document}

\begin{frame}{Example}
 \begin{enumerate}
  \item Hello there
 \end{enumerate}
\end{frame}

\end{document}
0

2 Answers 2

13

The code for creating the boxes can be found in beamerbaseauxtemplates.sty. You can wrap it in a new command so you can use it outside enumerations:

\documentclass[mathserif,xcolor=svgnames]{beamer}
\setbeamertemplate{enumerate items}[square]
\begin{document}

\newcommand\boxednumber[1]
{%
  \hbox{%
    \usebeamerfont*{item projected}%
    \usebeamercolor[bg]{item projected}%
    \vrule width2.25ex height1.85ex depth.4ex%
    \hskip-2.25ex%
    \hbox to2.25ex{%
      \hfil%
      \color{fg}#1%
      \hfil}%
  }%
}

\begin{frame}{Example}
 \begin{enumerate}
  \item Hello there
 \end{enumerate}

Let's talk about item \boxednumber{1}
\end{frame}

\end{document}
12

Here's another way to do this but using \label and \ref instead. I created a \squareref command which will enclose its reference in a square box. I did this originally for the ball type references, so I've included that code in the example as well. The basic code is taken from the same beamer source as in Jake's answer.

\documentclass{beamer}

\newcommand*{\squareref}[1]{
  \hbox{%
    \usebeamerfont*{item projected}%
    \usebeamercolor[bg]{item projected}%
    \vrule width2.25ex height1.85ex depth.4ex%
    \hskip-2.25ex%
    \hbox to2.25ex{%
      \hfil%
      \color{fg}\ref{#1}%
      \hfil}%
  }%
}

\newcommand*{\ballref}[1]{%
    \begin{pgfpicture}{-1ex}{-0.65ex}{1ex}{1ex}
    \usebeamercolor[fg]{item projected}
    {\pgftransformscale{1.75}\pgftext{\normalsize\pgfuseshading{bigsphere}}}
    {\pgftransformshift{\pgfpoint{0pt}{0.5pt}}
      \pgftext{\usebeamerfont*{item projected}\ref{#1}}}
  \end{pgfpicture}}%


\begin{document}
\setbeamertemplate{enumerate items}[square]

\begin{frame}

\begin{enumerate}
\item\label{item1} Go to \squareref{item2}
\item\label{item2} Go to \squareref{item1}
\end{enumerate}
\setbeamertemplate{enumerate items}[ball]

\begin{enumerate}
\item\label{item3} Go to \ballref{item4}
\item\label{item4} Go to \ballref{item3}

\end{enumerate}

\end{frame}

\end{document} 

output of code

2
  • This solution did not worked for my long presentation until I changed the labels from "item1" "item2" to "one" and "two". With "itemX" I've got the bullets but with wrong numbers as follows 1 go to 2 and 2 go to 2
    – Ottorino
    Commented Apr 11, 2013 at 20:43
  • @Ottorino I'm not sure what you were doing exactly, but the code works as posted. Perhaps you had duplicate labels (which I did in the code you tried.) I've removed the duplicates now, in case that was the cause of the problem. There's no problem for the labels to have numbers in them.
    – Alan Munn
    Commented Apr 12, 2013 at 2:59

You must log in to answer this question.

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