1

I have a beamer presentation and an alert block. I want to insert a horizontal ruler to seperate text. To fit into the style of the presentation, it should match the color of the surrounding alert block. How can I use the color of the alert blocks title line? At the moment I am just using a color that matched okay-ish in my opinion.

\begin{center}
    \textcolor{BrickRed}{\hrulefill}
\end{center}

I am aware of the command \usebeamercolor[fg]{structure} text, but I do not know what to put for fg and structure to give be the desired color (yes, I checked the beamer documentation).

enter image description here

Extra: At the moment, the exact vertical positioning of the \hrulefill is achieved by two (annoyingly fine-tuned) \vspace-commands, one before and one after the ruler. Without these, there are huge gaps between the text and the ruler. Is there a better way to achieve a nice positioning?


Update

The problem with the color seems to be solved by the answer of samcarter. For the positioning problem I was pointed out to provide an MWE:

\documentclass[pdf]{beamer}

\usetheme{Malmoe}
\usecolortheme{beaver}
\usecolortheme{orchid}
\usefonttheme{professionalfonts}

\begin{document}

\begin{frame}{Frenet equations}

\begin{alertblock}{\textbf{Theorem:} Frenet equations}
    For the Frenet frame $(\bf t,\bf n)$ of a curve holds
    \begin{align*}
        \bf t'(t) &= \phantom+\kappa(t)\bf n(t),\\
        \bf n'(t) &= -\kappa(t)\bf t(t).
    \end{align*}
    %
    \vspace{-3em}
    \begin{center}
        \usebeamercolor[bg]{block title alerted}\hrulefill
    \end{center}
    %
    \vspace{-0.5em}
    The equations can be written in \emph{matrix form}:
    $$
        \begin{pmatrix}
        \bf t'\\\bf n'
        \end{pmatrix}=\begin{pmatrix}
        \phantom-0&\kappa\\-\kappa&0
        \end{pmatrix}\begin{pmatrix}
        \bf t\\\bf n
        \end{pmatrix}.
    $$
\end{alertblock}

\end{frame}

\end{document}
  • Use {\usebeamercolor[fg]{structure}\hrulefill} – Jasper Habicht Feb 2 '18 at 9:27
  • @JasperHabicht I know, I just wonder what to use for structure and fg. Any idea? – M. Winter Feb 2 '18 at 9:28
  • Just use structure and fg. This will select the appropriate color. – Jasper Habicht Feb 2 '18 at 9:28
  • @JasperHabicht Ah I see. Unfortunately the ruler becomes blue (color of the normal block I guess). I tried alert structure and alert block structure and structure alert but nothing worked. – M. Winter Feb 2 '18 at 9:31
  • 1
1

You can access the colour with \usebeamercolor[bg]{block title alerted}

\documentclass{beamer}

\usecolortheme{orchid}

\begin{document}

\begin{frame}
    \begin{alertblock}{block title}
        content...
    \end{alertblock}

    {\usebeamercolor[bg]{block title alerted}\rule{\textwidth}{2pt}}

\end{frame} 

\end{document}

The large vertical spacing mainly comes from the center environment, which is not necessary anyway for an element which spans the whole line.

\documentclass[pdf]{beamer}

\usetheme{Malmoe}  %% Themenwahl
\usecolortheme{beaver}
\usecolortheme{orchid}
\usefonttheme{professionalfonts}

\begin{document}

\begin{frame}{Frenet equations}

\begin{alertblock}{\textbf{Theorem:} Frenet equations}
    For the Frenet frame $(\bf t,\bf n)$ of a curve holds
    \begin{align*}
        \bf t'(t) &= \phantom+\kappa(t)\bf n(t),\\
        \bf n'(t) &= -\kappa(t)\bf t(t).
    \end{align*}%

    \vspace{-1em}
    {\usebeamercolor[bg]{block title alerted}\hrulefill}

    The equations can be written in \emph{matrix form}:
    \[\begin{pmatrix}
    \bf t'\\\bf n'
    \end{pmatrix}=\begin{pmatrix}
    \phantom-0&\kappa\\-\kappa&0
    \end{pmatrix}\begin{pmatrix}
    \bf t\\\bf n
    \end{pmatrix}.\]
\end{alertblock}

\end{frame}

\end{document}
  • Yeah, the center-environment was a leftover from when I used the \rule which was not as long as the block. However, why is there still such an insame amount of space below the first formula which I have to compensate with the \vspace{-1em}? – M. Winter Feb 2 '18 at 11:40
  • @M.Winter The space is not insane, it is the normal space after an align environment. The distance to a normal text line is the same, it just appears smaller as normal letters accent from their baseline and fill part of the space. Replace the rule with _ _ _ _ _ _ and you'll see that is the same space. To compensate this different appearance, the \vspace{-1em} reduce the space by approximately the height of normal letters. – user36296 Feb 2 '18 at 11:47
  • I see. I somehow imagined the ruler to be in the center of the line and not on the baseline. Thank you very much. – M. Winter Feb 2 '18 at 11:50
2

One simple hack is to redefine the Beamer block color into BrickRed, using

\setbeamercolor{block title}{bg=BrickRed,fg=black}

I've put together a simple example showcasing the effect, with a little help from this topic.

enter image description here

\documentclass[usenames,dvipsnames]{beamer}

\setbeamercolor{block title}{bg=BrickRed,fg=black}

\makeatletter
   \def\vhrulefill#1{\leavevmode\leaders\hrule\@height#1\hfill \kern\z@}
\makeatother

\begin{document}

\begin{frame}
\begin{block}{Theorem}
    \begin{center}
    some text

    \textcolor{BrickRed}{\vhrulefill{6pt}}

    some more text
    \end{center}    
    \end{block}
\end{frame}

\end{document}

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.