Document ClassesBeamer | Fix Overfull \hbox warnings with modified theme

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Fr00pY
Posts: 3
Joined: Tue Apr 10, 2012 4:18 pm

Beamer | Fix Overfull \hbox warnings with modified theme

Post by Fr00pY »

hey everyone,
i have a little problem with beamer and hope that this is the right session in the forum. i modified a theme of beamer in a way that it looks as i like it. everythings works fine and i'm happy with the result but i get some "Overfull \hbox" warnings and would like to know how to fix that without changing the layout.
i know that the way i modified the beamer class might be "horrible", but anyway, i'm here to learn how its done nice and elegant.
thanks in advance!

Code: Select all

\documentclass[10pt]{beamer}

\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage{helvet}

\usetheme{Berlin}

%colors==================================================
\definecolor{farbe1}{rgb}{0.2,0.2,0.2}
\definecolor{farbe2}{rgb}{0.3,0.3,0.3}
\definecolor{farbe3}{rgb}{0.8,0.8,0.8}
\definecolor{farbe4}{rgb}{0.9,0.9,0.9}

%set colors==============================================
\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{palette primary}{fg=farbe4,bg=farbe2}
\setbeamercolor{item}{fg=farbe2,bg=white}
\setbeamercolor{navigation symbols}{fg=black,bg=white}
\setbeamercolor{box1}{fg=farbe4,bg=farbe1}
\setbeamercolor{box2}{fg=farbe4,bg=farbe2}
\setbeamercolor{box3}{fg=farbe4,bg=farbe1}

%layout==================================================
\setbeamertemplate{footline}
       {%
              \vspace*{0mm}\hspace*{0\textwidth}%
              \begin{beamercolorbox}[wd=\textwidth,ht=1mm,dp=1mm,leftskip=1mm,rightskip=1mm]{box1}%
              \end{beamercolorbox}%
       }
\setbeamertemplate{headline}
       {%
              \vspace*{0mm}\hspace*{0\textwidth}%
              \begin{beamercolorbox}[wd=\textwidth,ht=2mm,dp=0.6mm,leftskip=1mm,rightskip=1mm]{box1}%
                    \hfill \textbf{\inserttitle} \hfill \textbf{\insertframenumber}%
              \end{beamercolorbox}\\
              \vspace{-0.1mm}
       }
\setbeamertemplate{frametitle}
       {%
               \hspace*{-0.1025\textwidth}
               \begin{beamercolorbox}[wd=.14\textwidth,ht=6mm,dp=2mm,leftskip=4mm,rightskip=1mm]{box1}%
                     X.Y
              \end{beamercolorbox}%
              \hspace*{.0237\textwidth}%
              \begin{beamercolorbox}[wd=1.0429\textwidth,ht=6mm,dp=2mm,leftskip=4mm,rightskip=1mm]{box2}%
                     \insertframetitle
              \end{beamercolorbox}
              \vspace*{-4mm}
       }

%infos===================================================
\title{title}
\date{\today}

%document===============================================
\begin{document}
\maketitle
\section{section}
       \subsection{subsection}
              \begin{frame}{frametitle}
              \end{frame}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Beamer | Fix Overfull \hbox warnings with modified theme

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Take care of the widths you use, to not exceed the text width.

For example here:

Code: Select all

\begin{beamercolorbox}[wd=1.0429\textwidth,ht=6mm,dp=2mm,leftskip=4mm,
  rightskip=1mm]{box2}%
  \insertframetitle
\end{beamercolorbox}
by wd=1.0429\textwidth it's already too wide for the frame. Furthermore, I would remove the line break \\ after such a box in the template.

Stefan
LaTeX.org admin
Fr00pY
Posts: 3
Joined: Tue Apr 10, 2012 4:18 pm

Beamer | Fix Overfull \hbox warnings with modified theme

Post by Fr00pY »

i tried that. the problem is, that \textwidth in the headline is as wide as the document, but in the frametitle it seems to be smaller. furthermore if set 1.0429\textwidth to 1\textwidth it doesn't change the warning.
i think the problem is the box containing "X.Y":

Code: Select all

                   \begin{beamercolorbox}[wd=.14\textwidth,ht=6mm,dp=2mm,leftskip=4mm,rightskip=1mm]{box1}%
                         X.Y
                  \end{beamercolorbox}%
if i delete it, the bigger \hbox is gone.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Beamer | Fix Overfull \hbox warnings with modified theme

Post by Stefan Kottwitz »

Fr00pY wrote:the problem is, that \textwidth in the headline is as wide as the document, but in the frametitle it seems to be smaller.
Perhaps you mean \paperwidth then, which is larger than \textwidth and means the width of the frame, not of the text area.

Stefan
LaTeX.org admin
Fr00pY
Posts: 3
Joined: Tue Apr 10, 2012 4:18 pm

Beamer | Fix Overfull \hbox warnings with modified theme

Post by Fr00pY »

\paperwidth works fine, but unfortunately it doesn't removes the main issue. i changed the \setbeamertemplate{frametitle} using \paperwidth:

Code: Select all

    \documentclass[10pt]{beamer}

    \usepackage[ngerman]{babel}
    \usepackage[latin1]{inputenc}
    \usepackage{helvet}

    \usetheme{Berlin}

    %colors==================================================
    \definecolor{farbe1}{rgb}{0.2,0.2,0.2}
    \definecolor{farbe2}{rgb}{0.3,0.3,0.3}
    \definecolor{farbe3}{rgb}{0.8,0.8,0.8}
    \definecolor{farbe4}{rgb}{0.9,0.9,0.9}

    %set colors==============================================
    \setbeamercolor{normal text}{fg=black,bg=white}
    \setbeamercolor{palette primary}{fg=farbe4,bg=farbe2}
    \setbeamercolor{item}{fg=farbe2,bg=white}
    \setbeamercolor{navigation symbols}{fg=black,bg=white}
    \setbeamercolor{box1}{fg=farbe4,bg=farbe1}
    \setbeamercolor{box2}{fg=farbe4,bg=farbe2}
    \setbeamercolor{box3}{fg=farbe4,bg=farbe1}

    %layout==================================================
    \setbeamertemplate{footline}
           {%
                  \vspace*{0mm}\hspace*{0\textwidth}%
                  \begin{beamercolorbox}[wd=\textwidth,ht=1mm,dp=1mm,leftskip=1mm,rightskip=1mm]{box1}%
                  \end{beamercolorbox}%
           }
    \setbeamertemplate{headline}
           {%
                  \vspace*{0mm}\hspace*{0\textwidth}%
                  \begin{beamercolorbox}[wd=\textwidth,ht=2mm,dp=0.6mm,leftskip=1mm,rightskip=1mm]{box1}%
                        \hfill \textbf{\inserttitle} \hfill \textbf{\insertframenumber}%
                  \end{beamercolorbox}\\
                  \vspace{-0.1mm}
           }
    \setbeamertemplate{frametitle}
           {%
%              \hspace*{-1cm}
              \begin{beamercolorbox}[wd=0.15\paperwidth,ht=6mm,dp=2mm,leftskip=4mm,rightskip=1mm]{box1}%
                     X.Y
              \end{beamercolorbox}%
              \hspace*{.0237\textwidth}%
              \begin{beamercolorbox}[wd=0.8\paperwidth=6mm,dp=2mm,leftskip=4mm,rightskip=1mm]{box2}%
                     \insertframetitle
              \end{beamercolorbox}
              \vspace*{-4mm}
           }

    %infos===================================================
    \title{title}
    \date{\today}

    %document===============================================
    \begin{document}
    \maketitle
    \section{section}
           \subsection{subsection}
                  \begin{frame}{frametitle}
                  \end{frame}
    \end{document}
removing or adding \hspace*{-1cm} results in the \hbox warning. but now the result looks far different from the beginning. how can i move the "X.Y" box to the left, make the frametitle box higher (why is it now smaller anyway...?) and bring it in one line with the "X.Y" box?
Post Reply