jolars / moloch

A LaTeX Beamer theme, forked from the metropolis theme
https://ctan.org/pkg/moloch
Creative Commons Attribution Share Alike 4.0 International
89 stars 5 forks source link

Uppercase frame titles do not work #17

Closed tflinkow closed 4 months ago

tflinkow commented 4 months ago

Using the example code from the blog post and the line \setbeamertemplate{frametitle}{\MakeUppercase{\insertframetitle}} (also from the blog post) will make frame titles simply disappear completely instead of making them uppercase.

MWE:

\documentclass{beamer}

\usetheme{moloch}

\title{Your Title}
\author{Your Name}
\institute{Your Institute}
\date{\today}

\setbeamertemplate{frametitle}{\MakeUppercase{\insertframetitle}}

\begin{document}
  \maketitle
  \section{First Section}
  \begin{frame}
    \frametitle{First Frame}
    Hello, world!
  \end{frame}
\end{document}

There are no errors or warnings.

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024) (format=lualatex 2024.3.29) 5 JUL 2024 23:18 system commands enabled.

samcarter commented 4 months ago

If you change the colour, you'll see that the frametitle is upper case:

\documentclass{beamer}

\usetheme{moloch}

\title{Your Title}
\author{Your Name}
\institute{Your Institute}
\date{\today}

\setbeamercolor{frametitle}{fg=black}
\setbeamertemplate{frametitle}{\MakeUppercase{\insertframetitle}}

\begin{document}
  \maketitle
  \section{First Section}
  \begin{frame}
    \frametitle{First Frame}
    Hello, world!
  \end{frame}
\end{document}
samcarter commented 4 months ago

If you would like the same look of the frametitle as in moloch:

\documentclass{beamer}

\usetheme{moloch}

\title{Your Title}
\author{Your Name}
\institute{Your Institute}
\date{\today}

\makeatletter
\defbeamertemplate{frametitle}{allcaps}{%
  \nointerlineskip%
  \begin{beamercolorbox}[%
      wd=\paperwidth,%
      sep=1.1ex,%
      leftskip=0.5ex,%
      rightskip=\the\glueexpr 0.5ex plus 1fill\relax,%
    ]{frametitle}%
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-0.4ex%
    \strut\MakeUppercase{\insertframetitle}\nolinebreak\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
        \else%
        {\usebeamerfont{framesubtitle}\vspace{-0.8ex}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\strut\par}%
      \fi
    }%
  \end{beamercolorbox}%
}
\makeatother

\setbeamertemplate{frametitle}[allcaps]

\begin{document}
  \maketitle
  \section{First Section}
  \begin{frame}
    \frametitle{First Frame}
    Hello, world!
  \end{frame}
\end{document}

document-3

tflinkow commented 4 months ago

Thanks @samcarter!

Just wondering, would that be the best way to emulate metropolis \metroset{titleformat=allsmallcaps} (or the allcaps options, for that matter)?

That's quite a lot of code in your reply, and it contains stuff like \glueexpr etc. that I would like to not have to mess with myself.

I think I'll go with

\let\oldframetitle\frametitle
\renewcommand{\frametitle}[1]{\oldframetitle{\MakeUppercase{#1}}}

because it's shorter and does not require me to define a template... unless this causes any issues with moloch?

jolars commented 4 months ago

Ah, I naively thought this would be easier to setup through beamer. Maybe I need to consider bringing this feature back. If I understand correctly it should be easier to accomplish now anyway.

samcarter commented 4 months ago

I think I'll go with

\let\oldframetitle\frametitle
\renewcommand{\frametitle}[1]{\oldframetitle{\MakeUppercase{#1}}}

because it's shorter and does not require me to define a template... unless this causes any issues with moloch?

You'll lose the ability to use \frametitle<2>{test} and similar.

samcarter commented 4 months ago

I think I'll go with

\let\oldframetitle\frametitle
\renewcommand{\frametitle}[1]{\oldframetitle{\MakeUppercase{#1}}}

because it's shorter and does not require me to define a template... unless this causes any issues with moloch?

This will also cause issues in case you have frame breaks, e.g. try

\documentclass{beamer}

\usetheme{moloch}

\title{Your Title}
\author{Your Name}
\institute{Your Institute}
\date{\today}

\makeatletter
\defbeamertemplate{frametitle}{allcaps}{%
  \nointerlineskip%
  \begin{beamercolorbox}[%
      wd=\paperwidth,%
      sep=1.1ex,%
      leftskip=0.5ex,%
      rightskip=\the\glueexpr 0.5ex plus 1fill\relax,%
    ]{frametitle}%
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-0.4ex%
    \strut\MakeUppercase{\insertframetitle}\nolinebreak\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
        \else%
        {\usebeamerfont{framesubtitle}\vspace{-0.8ex}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\strut\par}%
      \fi
    }%
  \end{beamercolorbox}%
}
\makeatother

%\setbeamertemplate{frametitle}[allcaps]

\let\oldframetitle\frametitle
\renewcommand{\frametitle}[1]{\oldframetitle{\MakeUppercase{#1}}}

\begin{document}

\begin{frame}[allowframebreaks]
\frametitle{test}
  abc

  abc

  abc

  abc

  abc

  abc

  abc

  abc

  abc

  abc

  abc 

  abc
  abc

  abc

  abc

  abc

  abc
\end{frame}

\end{document}
samcarter commented 4 months ago

and does not require me to define a template.

If you don't like defining templates, you could instead patch the existing one:

\documentclass{beamer}

\usetheme{moloch}

\title{Your Title}
\author{Your Name}
\institute{Your Institute}
\date{\today}

\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\MakeUppercase{\insertframetitle}}{}{}
\makeatother

\begin{document}
  \maketitle
  \section{First Section}
  \begin{frame}
    \frametitle{First Frame}
    Hello, world!
  \end{frame}
\end{document}
jolars commented 4 months ago

Okay, I've opened a PR that brings back support for title format modifications (#18). Could you please have a look and see if it's working as you expect, @tflinkow?

tflinkow commented 4 months ago

@jolars It seems to work fine for me, thanks! I didn't test standout frames but the regular frames work well.

tflinkow commented 4 months ago

Apologies again.

I've tried to use fontsetup now to load New Computer Modern as it provides small caps sans serif - but apparently not bold ones :/

How would I reset the frame title to not be bold but leave everything else (color, shape, size etc.) unchanged, so that I do get small caps for the frame titles?

\documentclass[11pt]{beamer}

\usetheme{moloch}

\molochset{
  titleformat=smallcaps
}

\usepackage{fontsetup}

\begin{document}
  \begin{frame}{Small Capitals Should Work}
    \scshape
    Small Capitals Should Work
  \end{frame}
\end{document}
image
samcarter commented 4 months ago

As a workaround

% !TeX TS-program = lualatex
\documentclass[11pt]{beamer}

\usetheme{moloch}
\setbeamerfont{frametitle}{series=\scshape}
\usepackage{fontsetup}

\begin{document}
  \begin{frame}
    \frametitle{Small Capitals Should Work}
    \scshape
    Small Capitals Should Work
  \end{frame}
\end{document}

document-1

samcarter commented 4 months ago

... or bold small caps with the helvet package:

\documentclass[11pt]{beamer}

\usepackage{helvet}
\usetheme{moloch}
\setbeamerfont{frametitle}{series=\bfseries\scshape}

\begin{document}
  \begin{frame}
    \frametitle{Small Capitals Should Work}
    \scshape
    Small Capitals Should Work
  \end{frame}
\end{document}

document-1