1

I want to modify the width of the colorbox of the frametitle. Metropolis defines the frametitle like this:

\defbeamertemplate{frametitle}{plain}{%
    \nointerlineskip%
    \begin{beamercolorbox}[%
        wd=\paperwidth,%
        sep=0pt,%
        leftskip=\metropolis@frametitle@padding,%
        rightskip=\metropolis@frametitle@padding,%
        ]{frametitle}%
        \metropolis@frametitlestrut@start%
        \insertframetitle%
        \nolinebreak%
        \metropolis@frametitlestrut@end%
    \end{beamercolorbox}%
}

The colored background should have a width like wd=0.25\paperwidth. How can I achieve this?

1 Answer 1

1

If you want to have a width of wd=0.25\paperwidth, just say so in the key and either set the frametitle template or define a new template with the *-version. However if the colorbox is smaller then the text width and if you still want to have it left aligned, we also need to move left to the outer edge by the text margin. Here is some sample code:

\documentclass{beamer}

\usetheme{metropolis}

\makeatletter
\defbeamertemplate*{frametitle}{modified}{%
    \nointerlineskip%
    \hspace{-\beamer@leftmargin}%
    \begin{beamercolorbox}[%
        wd=0.25\paperwidth,%
        sep=0pt,%
        leftskip=\metropolis@frametitle@padding,%
        rightskip=\metropolis@frametitle@padding,%
        ]{frametitle}%
        \metropolis@frametitlestrut@start%
        \insertframetitle%
        \nolinebreak%
        \metropolis@frametitlestrut@end%
    \end{beamercolorbox}%
}
\makeatother

\begin{document}

\section{Section}
\subsection{Subsection}
\begin{frame}
\frametitle{Frametitle}
Content1
\end{frame}

\subsection{Subsection 2}
\begin{frame}
\frametitle{Frametitle 2}
Content2
\end{frame}

\end{document}

Result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.