0

When I empty the block title in beamer it doesn't show the green color in Madrid theme. I want to get this color although when I empty the title as well as when give a title.

3

You could add \relax as title and if needed, also as subtitle:

\documentclass[]{beamer}

\usetheme{Madrid}

\begin{document}
\begin{frame}{\relax}%>>>
  No title in Madrid.
\end{frame}%<<<

\begin{frame}{\relax}{\relax}%>>>
  No title in Madrid.
\end{frame}%<<<

\end{document}

enter image description here

\relax doesn't work for a block environment. But for this you could use \strut or (if that is to big) \phantom{phantom Title} or something like that.

\documentclass[]{beamer}

\usetheme{Madrid}

\begin{document}
\begin{frame}{\relax}%>>>
  No title in Madrid.
  \begin{block}{\phantom{Tp}}
    Block without Title
  \end{block}
\end{frame}%<<<

\begin{frame}{\relax}{\relax}%>>>
  No title in Madrid.
\end{frame}%<<<

\end{document}

enter image description here

  • yes \phantom{Tp} works. No need \relax – alhelal Feb 24 '18 at 17:05
  • @alhelal at first I thought you meant the frame titles. It would have been better if you'd included a MWE in your question. – Skillmon Feb 24 '18 at 17:25
  • I also said block title and yes I should add a MWE. I guessed the code might be very simple, so I didn't add MWE. – alhelal Feb 24 '18 at 17:30
  • 2
    @alhelal A MWE would have made your question way less confusing - especially as green is not the default colour of ordinary blocks in Madrid. Even if the code is simple, it saves everybody trying to help you to start from scratch. – user36296 Feb 24 '18 at 17:41
  • 1
    @alhelal \relax does nothing by itself, but it is not an empty argument to the frame title, so the beamer template for the frame title gets displayed/used. It doesn't work for a block because those evaluate the size of the title and since \relax has no size... – Skillmon Feb 27 '18 at 8:01
2

If you want this behaviour for all blocks, you could change the definition of block begin to include an invisible element of whatever height the blue title area should have.

\documentclass{beamer}

\usetheme{Madrid}

\setbeamertemplate{block begin}{%
  \par\vskip\medskipamount%
  \begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true]%
    {\raggedright\usebeamerfont*{block title}\insertblocktitle
     \rule{0pt}{0.6em}%
    }%
    \raggedright%
    \usebeamerfont{block body}%
}

\begin{document}

\begin{frame}

\begin{block}{}
test
\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.