1

Is it possible to set a beamer template to be the same as another template? I define a template named "myTemplate page" and I would like that template to be the same as the "section page" template. The purpose of this is if someone change the theme that would likely change the section page template and I want myTemplate to change as well. For example, in the MWE, the Frankfurt theme set the section page parameters as colsep=-4bp,rounded=true,shadow=\beamer@themerounded@shadow. How can I pass those settings directly to "myTemplate page" without knowing them in advance?

\documentclass{beamer}
\usetheme{Frankfurt}

\AtBeginSection[]{%
\frame{\sectionpage}
}%

\def\myTemplatepage{\usebeamertemplate*{myTemplate page}}

\defbeamertemplate*{myTemplate page}{default}[1][]
{
    \begingroup
    \centering
    {\usebeamerfont{section name}
    \usebeamercolor[fg]{section name} Some text}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center,#1]{section title}
    \usebeamerfont{section title} Some other text \par
    \end{beamercolorbox}
    \endgroup
}

\begin{document}
\section{First section}        
\begin{frame}{}
\myTemplatepage 
\end{frame}
    
\end{document}

UPDATE

I tried to add

\defbeamertemplateparent{section page}{myTemplate page}[1][default]{[#1]}

(as recommended by TobiBS) but it seems to do nothing. Also, I guessed that the template modifications should come after defining the template parent so I moved the \usetheme{Frankfurt} after the \defbeamertemplateparent, with no result.

I did not find many examples with \defbeamertemplateparent or \defbeamertemplatealias. I probably don't understand how they work. But it feels like it should work!

UPDATE 2

I looked at the the themes provided in the beamer class and I think that the only things that changes from one another that affect the section page template is the round corners and the shadow. So I decided to manualy check those two things in the preambule and apply it to myTemplate page. This is really not the solution I wanted but it is the best I can do for now. I would have prefer something more general. I used the etoolbox package for boolean tests.

\AtBeginDocument{%
\@ifpackageloaded{beamerinnerthemerounded}{%
\ifcsdef{beamer@themerounded@shadow}{%
\edef\x{\beamer@themerounded@shadow}%
\ifboolexpe{bool {\x}}{%
\setbeamertemplate{myTemplate page}[default][colsep=-4bp, rounded=true, 
shadow=true]%
}{\setbeamertemplate{myTemplate page}[default][colsep=-4bp, rounded=true]}
}{}%
}{}%
}%  
6
  • I would like to know if the lack of answer to this question is because the question is not clear, not interesting, difficult or impossible? I would be happy to clarify or try ideas of solutions.
    – sipaq11
    Nov 21, 2019 at 15:33
  • Probably related tex.stackexchange.com/questions/448010/how-to-reuse-code
    – BambOo
    May 10, 2020 at 15:18
  • Have you looked at the \defbeamertemplatealiasand \defbeamertemplateparent commands?
    – TobiBS
    Aug 27, 2020 at 14:37
  • @TobiBS I did not know those commands and I really thought it would work. I updated the question to show what I tried. I appreciate your help.
    – sipaq11
    Sep 25, 2020 at 14:31
  • @sipaq11 I am a bit confused now. What do you actually want to achieve? Do you want the \myTemplatepage look like a \sectionpage? I am asking because they are neither rounded, nor shaded in the Frankfurt theme, only the \titlepage is.
    – TobiBS
    Oct 13, 2020 at 19:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.