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]}
}{}%
}{}%
}%  
sipaq11
  • 103
  • 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 '19 at 15:33
  • Probably related https://tex.stackexchange.com/questions/448010/how-to-reuse-code – BambOo May 10 '20 at 15:18
  • Have you looked at the \defbeamertemplatealiasand \defbeamertemplateparent commands? – TobiBS Aug 27 '20 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 '20 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 '20 at 19:40
  • @TobiBS It is exactly what I want : \myTemplatepage looks like a \sectionpage. As for the rounded and shaded, I don't really know how beamer works so I could be wrong but my understanding is : the line \useinnertheme[shadow=true]{rounded} in beamerthemeFrankfurt.sty calls for \usepackage[{shadow=true}]{beamerinnerthemerounded} in wich there is some setbeamertemplate, in particular \setbeamertemplate{section page}[default][colsep=-4bp,rounded=true,shadow=\beamer@themerounded@shadow]. Maybe the problem is the definition of myTemplate. – sipaq11 Oct 15 '20 at 00:56
  • Instead of creating your own section page, I would try yo keep the original one and add to/patch it so that it looks like you want. Which modifications do you need compared to the default section page? – samcarter_is_at_topanswers.xyz Dec 19 '23 at 11:53
  • @samcarter_is_at_topanswers.xyz I want a Chapter page, so like the section page but with "Chapter" word and using my chapter counter. – sipaq11 Dec 20 '23 at 14:34

1 Answers1

1

Beamer's structure is not meant to deal with chapters. Instead I would use \part as the next sectioning level above sections. The word "Part" can easily be replaced with "Chapter" or whatever you want to call them.

\documentclass{beamer}
\usetheme{Frankfurt}

\renewcommand\partname{Chapter}

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

\AtBeginPart{ \frame{\partpage} }

\begin{document} \part{Chapter title} \section{First section} \begin{frame} content... \end{frame}
\end{document}

enter image description here


If really want to create chapters yourself, you could use the existing section page and change some words:

\documentclass{beamer}
\usetheme{Frankfurt}

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

\newcounter{chapter} \setcounter{chapter}{42}

\newcommand{\chapterpage}[1]{ \renewcommand{\sectionname}{Chapter} \renewcommand{\insertsectionnumber}{\thechapter} \renewcommand{\insertsection}{#1} \sectionpage }

\begin{document} \begin{frame}{} \chapterpage{Some title} \end{frame} \section{First section}
\end{document}

enter image description here