1

for quite a while i've had a solution to this using tikz.
i have some code that calculates a height dependent on the heights of the frametitle (including line breaks) and of the framesubtitle (if it is present). i then use tikz to draw a line at this calculated height. i now find myself needing to use tikzexternalize and if there happens to be more than one tikz picture then the frame content and tikz images are lost.

so, the question is, how can i draw a horizontal line of defined width and color at a specified height on the frame (relative to the top) without tikz? this was how i did it before.

\newcommand{\topline}{%
  \calculateLengths{0}
  \tikz[remember picture,overlay] {%
    \draw[riceBlue] ([yshift=-\contentheadheight+6pt,xshift=2cm]current page.north west)
                 -- ([yshift=-\contentheadheight+6pt,xshift=\paperwidth-2cm]current page.north west);
  }%
}

the calculateLengths command found the lower edge of the frametitle and framesubtitle.

1 Answer 1

2

The beamer way would be to use an otherwise empty beamercolorbox at the end of the frametitle template. The colour can be adjusted using the usual \setbeamercolor mechanism and the thickness of the line by modifying the value in colsep=1.5pt

\documentclass[xcolor={dvipsnames},aspectratio=1610]{beamer}

\setbeamercolor{lower separation line head}{bg=red}

\makeatletter
\setbeamertemplate{frametitle}{%
  \nointerlineskip%
    \vskip0.3cm%
   \begin{beamercolorbox}[wd=\paperwidth,leftskip=.3cm,rightskip=.3cm plus1fil,vmode]{frametitle}%
        \begin{minipage}{2cm}%
            \includegraphics[height=1.2cm]{example-image-a}%
        \end{minipage}%
        \begin{minipage}{\dimexpr\paperwidth-4.6cm\relax}%
    \usebeamerfont*{frametitle}\insertframetitle%
      \ifx\insertframesubtitle\@empty%
        \strut\par%
      \else
        \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
      \fi%%
        \end{minipage}%
        \begin{minipage}{2cm}%
            \hfill
            \includegraphics[height=1.2cm]{example-image-b}%
        \end{minipage}%
  \end{beamercolorbox}%
  \vskip1ex
  \begin{beamercolorbox}[colsep=1.5pt,wd=\paperwidth]{lower separation line head}
  \end{beamercolorbox}
}
\makeatother

\usepackage{tikz}

\begin{document}

\begin{frame}
    \frametitle{title}
\end{frame}

\begin{frame}
    \frametitle{multiline very very very very very very very very very long title}
    \framesubtitle{title}
\end{frame}

\begin{frame}
    \frametitle{title}
    \framesubtitle{title}
\end{frame}

\end{document}

enter image description here

2
  • Thanks, this is nearly perfect. one follow up question though, is it possible to have the location of the left and right images dependent on distance from the top of the page, rather than centered about the height of the beamercolorbox? Commented Dec 11, 2017 at 19:12
  • @jameszabel You could have a fixed alignment from the top if you use columns. Commented Dec 11, 2017 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .