2

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

12
  • The title of your post and the body seem to be asking opposite things ...
    – Joseph Wright
    Commented Jun 18, 2017 at 21:52
  • @JosephWright Ahhhhhh. Good point. Didn't read the title well enough, Commented Jun 18, 2017 at 21:53
  • @Dr.ManuelKuehner Added more explanation.
    – bkarpuz
    Commented Jun 18, 2017 at 21:59
  • @JosephWright Corrected.
    – bkarpuz
    Commented Jun 18, 2017 at 22:00
  • 2
    Add {~} like this: \begin{frame}{~} \framesubtitle{SubTittle} Text. \end{frame}, does this seem right?
    – AboAmmar
    Commented Jun 18, 2017 at 22:11

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .