TransWikia.com

Beamer Metropolis: Change width of frametitle colorbox

TeX - LaTeX Asked by Sr. Schneider on December 4, 2020

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.25paperwidth. How can I achieve this?

One Answer

If you want to have a width of wd=0.25paperwidth, 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.25paperwidth,%
        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

Correct answer by TobiBS on December 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP