2

It it possible to use \framesubtitle without \frametitle in Beamer? Because, I want to use \frametitle for sections and \framesubtitle for subsections.

bkarpuz
  • 2,437
  • The title of your post and the body seem to be asking opposite things ... – Joseph Wright Jun 18 '17 at 21:52
  • @JosephWright Ahhhhhh. Good point. Didn't read the title well enough, – Dr. Manuel Kuehner Jun 18 '17 at 21:53
  • @Dr.ManuelKuehner Added more explanation. – bkarpuz Jun 18 '17 at 21:59
  • @JosephWright Corrected. – bkarpuz Jun 18 '17 at 22:00
  • Did you try it? Wouldn't that be a lot faster than asking here and waiting for an answer? – cfr Jun 18 '17 at 22:04
  • @Dr.ManuelKuehner But what's the question, then? Does the code give an error? If not, what? – cfr Jun 18 '17 at 22:06
  • I want to use frame title for sections and frame subtitle for subsections. -- Do you look for something like https://tex.stackexchange.com/questions/17230/beamer-how-to-make-each-frame-appear-in-the-pdf-toc or http://tex.stackexchange.com/questions/66519/make-each-frame-not-slide-appear-in-the-pdf-bookmarks-with-beamer ? – knut Jun 18 '17 at 22:09
  • :( @Dr.ManuelKuehner I wasn't suggesting you should do the OP's work .... – cfr Jun 18 '17 at 22:10
  • 2
    Add {~} like this: \begin{frame}{~} \framesubtitle{SubTittle} Text. \end{frame}, does this seem right? – AboAmmar Jun 18 '17 at 22:11
  • @AboAmmar But I dont want the belt created by \frametitle{~}. – bkarpuz Jun 18 '17 at 22:14
  • @knut Not really (my problem is just showing subsection names in framesubtitle part without requiring to use frametitle) but thank you. – bkarpuz Jun 18 '17 at 22:17
  • If I recall correctly, [tag:beamer] will typeset the subtitle only if the title is nonempty. In other words, you have to create that belt and then hide it manually. – Symbol 1 Jun 20 '17 at 15:39

1 Answers1

4

Two approaches.

The first approach defines a magic word called please hide this title. Whenever the title is exactly this string, it will be hidden.

This definition of frametitle template is simply a copy of the original one in beamerouterthemedefault.sty line 149-169, except that the line generating the title is wrapped in a \ifx.

\documentclass{beamer}
\usetheme{Madrid}

\begin{document}

\makeatletter
\def\stringpleasehidethistitle{{please hide this title\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle continuation}\fi}}
\defbeamertemplate*{frametitle}{only sub}[1][left]
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,#1,wd=\the\@tempdima]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
    \ifx\insertframetitle\stringpleasehidethistitle%   check if magic word presents
    \else%                                             check if magic word presents
      \strut\insertframetitle\strut\par%               check if magic word presents
    \fi%                                               check if magic word presents
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
    \vskip-1ex%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
}

\frame{{please hide this title}{only subtitle}}
\frame{{I want title}{title appears!}}
\frame{{please hide this title}{only subtitle again!}}
\frame{{I want title the second time}{title appears again!}}

\end{document}


The second approach defines an alternative frametitle template which ironically shows no frametitle. This definition is simply a copy of the original one in beamerouterthemedefault.sty line 149-169, except that the line generating the title is commented out.

\documentclass{beamer}
\usetheme{Madrid}

\begin{document}

\makeatletter
\defbeamertemplate*{frametitle}{only sub}[1][left]
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,#1,wd=\the\@tempdima]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
    %\strut\insertframetitle\strut\par% <-- This line is commented out
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
    \vskip-1ex%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
}

\frame{{this title will be ignored}{only subtitle}}
\setbeamertemplate{frametitle}[default]
\frame{{switch back to the default}{title appears!}}
\setbeamertemplate{frametitle}[only sub]
\frame{{this title will be ignored again}{only subtitle again!}}
\setbeamertemplate{frametitle}[default]
\frame{{switch back to the default again}{title appears again!}}

\end{document}

The result is basically the same as before.

Symbol 1
  • 36,855