How to add block title section and color without the title in beamer?

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.

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

\documentclass[]{beamer}

\begin{document}
\begin{frame}{\relax}%>>>
\end{frame}%<<<

\begin{frame}{\relax}{\relax}%>>>
\end{frame}%<<<

\end{document}


\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}

\begin{document}
\begin{frame}{\relax}%>>>
\begin{block}{\phantom{Tp}}
Block without Title
\end{block}
\end{frame}%<<<

\begin{frame}{\relax}{\relax}%>>>
\end{frame}%<<<

\end{document}


• 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
• @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
• @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

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}

\setbeamertemplate{block begin}{%
\par\vskip\medskipamount%
{\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}