3

I am trying to edit a beamerthemeMyTheme.sty file to have the exampleblock become framed/bordered. While I have seen examples such as that in

What I cannot seem to do is edit the style file to make each exampleblock a framed block with a specific frame color. At the moment I am continuously fumbling with the concepts of the style file layout and syntax present in this for ex:

\defbeamertemplateparent{blocks}[framed]{block begin,block end}[1][{[#1]}

What is the [framed] component doing here? Is it a parameter or a flag to specify a new usage of the block environment used? Is this overriding the block environment or when the word "blocks" is used instead? What are the parameters in [1][{[#1]} setting or referring to? Another statement in the first link above:

\defbeamertemplate{block begin}{framed}[1][]

Is this referring to every block that will be created or a block that will be flagged/set as "framed"? Again what is the number referring to?

This code produces a framed block using \usepackage{tcolorbox}:

\begin{frame}{test}
\begin{tcolorbox}[title=My title,
colback=red!5!white,
colframe=red!75!black,
fonttitle=\bfseries]
This is a tcolorbox
Further text.
\end{tcolorbox}
\end{frame}

Overall, I would like to understand how to create the theme style for adding framed blocks to exampleblocks, while understanding what the statements are doing. I have been trying to get through the book 'The TEXbook' by Donald E. Knuth, but I seem to be missing the big picture.

6

A theme definition is more complex than blocks definition, but if you just want to use framed blocks instead of default beamer blocks don't need to define a new theme, just define new blocks.

Following example shows how to define new tcolorboxes to use as example and alert blocks and respecting beamer defined colors for these blocks. There are geometric differences between default beamer and tcolorboxes, but they can be solved adding geometry options in boxes definition.

\documentclass{beamer}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}

\usetheme{Warsaw}

\newtcolorbox{myexampleblock}[2][]{%
colframe = block title example.bg,
coltitle = block title example.fg,
colback = block body example.bg,
title = #2,
#1
}

\newtcolorbox{myalertblock}[2][]{%
colframe = block title alerted.bg,
coltitle = block title alerted.fg,
colback = block body alerted.bg,
title = #2,
#1
}

\begin{document}

\begin{frame}
\begin{exampleblock}{Example}
this a beamer block example
\end{exampleblock}

\begin{myexampleblock}{Example}
this a framed block example
\end{myexampleblock}

\begin{alertblock}{Alert}
this a beamer alerted block
\end{alertblock}

\begin{myalertblock}{Alert}
this a framed alerted block 
\end{myalertblock}
\end{frame}

\end{document}

enter image description here

Update:

In order to create a beamertheme file with these definitions, we extract all of them (and packages?) into beamerthemeTest.sty file and leave it into the working folder.

% beamerthemeTest.sty
\RequirePackage[most]{tcolorbox}

\usetheme{Warsaw}

\newtcolorbox{myexampleblock}[2][]{%
colframe = block title example.bg,
coltitle = block title example.fg,
colback = block body example.bg,
title = #2,
#1
}

\newtcolorbox{myalertblock}[2][]{%
colframe = block title alerted.bg,
coltitle = block title alerted.fg,
colback = block body alerted.bg,
title = #2,
#1
}

Now main file looks like:

\documentclass{beamer}

\usetheme{Test}

\begin{document}

\begin{frame}
\begin{exampleblock}{Example}
this a beamer block example
\end{exampleblock}

\begin{myexampleblock}{Example}
this a framed block example
\end{myexampleblock}

\begin{alertblock}{Alert}
this a beamer alerted block
\end{alertblock}

\begin{myalertblock}{Alert}
this a framed alerted block 
\end{myalertblock}
\end{frame}

\end{document}
  • Can you include in your answer how this can be put into a style file? The beamerthemeX.sty – Vass Sep 14 '17 at 14:25
  • 1
    @Vass Done! Look at updated answer. – Ignasi Sep 14 '17 at 14:56
  • that is great, thank you, now if you could be so kind as to show me how to override the 'alertblock' in the style file to show the 'myalertblock' style instead as default; that would be grand. – Vass Sep 14 '17 at 15:58
1

I am not sure I understood the whole question. I may help as far as the setbeamertemplateparent is concerned.

From beamer's manual :

    \defbeamertemplateparent{⟨parent template name⟩}[⟨predefined option name⟩]{⟨child template list⟩}[⟨argument number⟩][⟨default optional argument⟩]{⟨arguments for children⟩}
The effect of this command is that whenever someone calls \setbeamertemplate{⟨parent template name⟩}{⟨args⟩}, the command \setbeamertemplate{⟨child template name⟩}{⟨args⟩} is called for each ⟨child template name⟩ in the ⟨child template list⟩.

So, in

\defbeamertemplateparent{blocks}[framed]{block begin,block end}[1][{[#1]}

the «framed» is a predefined option name and the [1] means there is only one argument. I prefer not to dig dipper in understanding the whole statement, since I may get wrong. I understand however that your defbeamertemplate example works only for blocks that are flagged as framed.

I also think beamer manual will be more helpful that Knuth's book for this peculiar question.

  • how would I then use the statements to include a frame from tcolorbox onto the exampleblock? Does the 'framed' option need to be there, and what does it actually do? What if I don't want to have to flag it as framed and to apply to each exampleblock? Even when I try to use this flagged version, it does not compile, how do you use the flagged as framed version of example block? – Vass Sep 13 '17 at 19:02
  • Your question is quite beyond my skills. I would try something like \defbeamertemplate{block begin}{framed}[1][\begin{tcolorbox}[title=#1]] – sztruks Sep 13 '17 at 21:13

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.