2

I managed to repeat this example for customizing a beamer style. Now I would like to automatically insert the section and sub-section titles in the head of each slide, without necessity of setting \frametitle, ideally through the .sty files (i.e. beamer outer theme) and not in the .tex file.

I adapted the beamerouterthemetexsx.sty of the cited example in this way (see the comments):

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{texsx}[1][]
{
\vskip1cm%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle} 
  \begin{tikzpicture}
  \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);
  \fill[orange] (0,0) rectangle(2.95,1.2);
  \fill[blue!50!cyan!80] (3.05,0) rectangle(\the\paperwidth,1.2);
   % In the next part I replaced \insertframetitle by \insertsection
   % In the same way I replaced \insertframesubtitle by \insertsubsection
   \ifx\insertframesubtitle\@empty%
      {\node[anchor=west, white,font=\large] at (3.2,0.61){\insertsection};}
      \else%
      {\node[anchor= west, white,font=\large] at (3.2,0.81){\insertsection};%
       \node[anchor= west, white,font=\small] at
       (3.2,0.41){\insertsubsection};}%
      \fi
  \end{tikzpicture}
  \end{beamercolorbox}
}

\mode<all>

My document's source looks like this:

\documentclass[aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\title{My first attempt}
\date[today]{\today}
\author[Miguel]{Miguel Alvarez}

% use custom theme
\usetheme{texsx}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\section{The first lesson}

\subsection{Before the first break}

\begin{frame}
Blank frame
\end{frame}

\begin{frame}{auto}
Frame with title
\end{frame}

\begin{frame}{auto}{auto}
Frame with title and sub-title
\end{frame}

\end{document}

Is there a simple way to get automatically the title and subtitle in a slide by \begin{frame} without necessity of setting frame title and subtitle, which won't be used in any case (as by \begin{frame}{auto}{auto})?

In other words, for the code

\begin{frame}
Blank frame
\end{frame}

I got:

enter image description here

BUT I was expecting:

enter image description here

Migue Lo
  • 161
  • 1
    Well, I am not sure I understand your problem ... I tried to compile your example (using the theme you proposed) and it failed. So I added \RequirePackage in your .sty just after \mode<presentation> and replaced \usetheme{texsx} with \useoutertheme{texsx} and everything seems to work fine. Or I totally missed your question. – BambOo Apr 27 '20 at 17:19
  • I was expecting to get a slide with title and sub-title already after the title slide. The example is to show that in the current version I need to set a frame title (auto is the one) and frame sub-title to get the head-bar, although section and subsection are already set. – Migue Lo Apr 27 '20 at 17:23
  • Could you edit your question with a visual output of what you would like ? – BambOo Apr 27 '20 at 17:25
  • Ok, I see, the solution proposed here seems to work in your case. – BambOo Apr 27 '20 at 18:44
  • Thanks @BambOo I had seem this solution and I though, it may work only at .tex preamble, which is not the optimal way. I inserted the suggested lines in beamerthemetexsx.sty and it is working but only for the section and not for the sub-section. – Migue Lo Apr 27 '20 at 20:00
  • Could you edit your snippet to reflect the modified code ? – BambOo Apr 28 '20 at 16:01
  • Any news ?????? – BambOo May 10 '20 at 11:50
  • Sorry @BambOo for leaving the discussion but I went busy and in the meantime I think, that it is not bad at all to have the option of a fully blank slide, despite the longer code for "normal" slides. Thus I used \begin{frame}[t]{auto}{auto} for start a slide in the desired layout. – Migue Lo Jul 28 '20 at 20:15

0 Answers0