9

To modify the definition of a command we use \renewcommand, but how about modify a beamer template. For example if we change itemize item like this:

\defbeamertemplate{itemize item}{triangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} 

We get the error:

! LaTeX Error: Command \beamer@@tmpop@itemize item@triangle already defined.

This is an example of that:

\documentclass{beamer} \defbeamertemplate{itemize item}{triangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} \begin{document} \begin{frame} \setbeamertemplate{itemize item}[ball] \begin{itemize} \item text \item text \end{itemize} \setbeamertemplate{itemize item}[tiangle] \begin{itemize} \item text \item text \end{itemize} \end{frame} \end{document} 

1 Answer 1

14

The effect of \defbeamertemplate is to install (beamer's jargon) the option specified in <predefined option> for the template whose name is <element name>. The command has the following (simplified) syntax:

\defbeamertemplate{<element name>}{<predefined option>}[<argument number>][<default optional argument>]{<predefined text>} 

Since itemize item with predefined option triangle has already been installed (for example, in beamerbaseauxtemplates.sty and beamerinnerthemedefault.sty), your attempt obviously produces an error.

To prevent this, you can use another string for the predefined option

\defbeamertemplate{itemize item}{mytriangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} 

and then

\setbeamertemplate{itemize item}[mytriangle] 

A compete example:

\documentclass{beamer} \defbeamertemplate{itemize item}{mytriangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} \begin{document} \begin{frame} \setbeamertemplate{itemize item}[ball] \begin{itemize} \item text \item text \end{itemize} \setbeamertemplate{itemize item}[mytriangle] \begin{itemize} \item text \item text \end{itemize} \end{frame} \end{document} 

The resulting lists:

enter image description here

If you use the starred version then, besides setting the predefined template option, \setbeamertemplate is immediately used for this option. So

\defbeamertemplate*{itemize item}{mytriangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} 

is equivalent to

\defbeamertemplate{itemize item}{mytriangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} \setbeamertemplate{itemize item}[mytriangle] 

Look at the following example

\documentclass{beamer} \defbeamertemplate*{itemize item}{mytriangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} \begin{document} \begin{frame} \begin{itemize} \item text \item text \end{itemize} \setbeamertemplate{itemize item}[ball] \begin{itemize} \item text \item text \end{itemize} \end{frame} \end{document} 

The result:

enter image description here

Another option, if you want to overwrite the original installment of an element is to first undefine the conflicting command. For example, when you use

\defbeamertemplate{itemize item}{triangle}{<definition>} 

the command \beamer@@tmpop@itemize item@triangle (notice the space in the name) gets internally defined using \newcommand (that's why simply trying to do another

\defbeamertemplate{itemize item}{triangle}{<definition>} 

will trigger an error). You can prevent the error by undefining the command:

\documentclass{beamer} \expandafter\let\csname beamer@@tmpop@itemize item@triangle\endcsname\relax \defbeamertemplate{itemize item}{triangle} {\scriptsize\raise1.25pt\hbox{\donotcoloroutermaths$\blacktriangleleft$}} \begin{document} \setbeamertemplate{itemize item}[triangle] \begin{frame} \begin{itemize} \item text \item text \end{itemize} \setbeamertemplate{itemize item}[ball] \begin{itemize} \item text \item text \end{itemize} \end{frame} \end{document} 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.