# beamer full width hrule below frame title

I want to create a beamer template with a horizontal rule below every frame title.

The line should start just below the first letter of the title and extend until the very end of the frame.

Desired result:

The solution should be flexible enough to handle different font sizes and long titles spanning two lines. However, the vertical position of rule should not adapt to the height of the characters used in the frame title (e.g., whether or not the characters extend below to the baseline). To clarify:

To create a rule spanning the entire width of the frame, I use \makebox[\linewidth][l]{\rule{\paperwidth}{0.4pt}}, as suggested by others. An undesired side-effect of using \makebox is that it behaves differently from \hrule, e.g., it has a different height.

I solved the problem of fluctuating positioning of the rule by using \vphantom{g} in the frame title, but another solution might be more elegant.

\documentclass[t,9pt]{beamer}

\setbeamertemplate{frametitle}{%
\usebeamerfont{frametitle}\insertframetitle%
\vphantom{g}% To avoid fluctuations per frame
%\hrule% Uncomment to see desired effect, without a full-width hrule
\makebox[\linewidth][l]{\rule{\paperwidth}{0.4pt}}%
}

\begin{document}
\begin{frame}{Frame Title}
Frame contents.
\end{frame}
\end{document}


How do I get the desired result of a line below the frame title running until the right end of the frame?

I understand that you looking for:

\documentclass[t,9pt]{beamer}

\setbeamertemplate{frametitle}{%
\usebeamerfont{frametitle}\insertframetitle%
\vphantom{g}% To avoid fluctuations per frame
%\hrule% Uncomment to see desired effect, without a full-width hrule
\hspace*{-\dimexpr0.5\paperwidth-0.5\textwidth}% <-- calculation of left margin width
\rule[0.5\baselineskip]{\paperwidth}{0.4pt}%
}

\begin{document}
\begin{frame}{Frame Title }
Frame contents.
\end{frame}
\end{document}


Edit If you like to have less vertical space after horizontal rule, than try the following:

\setbeamertemplate{frametitle}{%
\usebeamerfont{frametitle}\insertframetitle%
\vphantom{g}% To avoid fluctuations per frame
%\hrule% Uncomment to see desired effect, without a full-width hrule
\par\hspace*{-\dimexpr0.5\paperwidth-0.5\textwidth}\rule[0.5\baselineskip]{\paperwidth}{0.4pt}
\par\vspace*{-\baselineskip}% <-- reduce vertical space after rule
}


which gives

• Nope, I wasn't looking for the negative hspace you added. However, omitting this, your answer solves my question, although I find a solution with leaders cleaner. – timothymctim Dec 11 '16 at 19:30
• I consider the following sentence your question: "To create a rule spanning the entire width of the frame" :(. – Zarko Dec 11 '16 at 20:24
• I'm sorry for the confusion. I also dislike the fact that I posted a question that I could answer myself in the end, even tough I have been stuck with this problem for quite some time. Still, I greatly appreciate your quick(!) answer. – timothymctim Dec 12 '16 at 23:36

Using another answer using \leaders, I solved my issue. Additionally, a cleaner solution is to use \strut instead of \vphantom{g}.

\setbeamertemplate{frametitle}{%
\usebeamerfont{frametitle}\insertframetitle\strut%
\vskip-.25\baselineskip%

Note that I’ve moved the line ¼ baselineskip up. This makes the line run over the descenders (that’s actually what I needed).