Trying to answer How to add the footnote in the right down corner with the background color(only page)&change time background color I wanted to calculate beamercolorbox width as wd=\pagewidth-\beamer@sidebarwidth but if failed, even with \usepackage{calc}. Do you know why?

Next you have an example to test it. First solution (with calc) doesn't work, second and third (with \addtolength and pgf-calc library) work.


  % wd=5cm-1cm does not work
  First box

  First box

  \begin{beamercolorbox}[wd=\lengthb cm]{sidebar}
  First box


enter image description here

  • 5
    beamer is pre-pgfkeys era. I didn't check it but probably the wd= is directly stored in a dimen and there is no possibility to catch the calculation. You might try \dimexpr...\relax if luck is on our side it should work :)
    – percusse
    Commented Oct 23, 2013 at 8:54
  • @percusse That's an answer right there.
    – jub0bs
    Commented Oct 23, 2013 at 9:02
  • @percusse So, this is the normal behaviour. Isn't it? It's is not possible to use calc to set beamercolor boxes size.
    – Ignasi
    Commented Oct 24, 2013 at 8:01
  • The calc package is nice but not really bullet-proof. I would stick to \dimexpr construct in this case. @percusse I think you should make it an answer.
    – yo'
    Commented Oct 24, 2013 at 14:51
  • @percusse: sir, you should make an answ... oh wait. :) Commented Oct 24, 2013 at 16:05

2 Answers 2


The PGF-like keys being filtered whether the argument is a dimen or a computation or else type of branching came later chronologically. Thus beamer, in a sense, predates the pgfkeys way of working and we should not expect much of the flexibility from beamer options as they are quite esoteric which might be, arguably, the reason why pgfkeys are developed in the first place.

In this case the key gets the argument literally and tries to give it to a dimen but the 5cm causes TeX to stop scanning and you have the dangling -1cm printed. A possible solution is to make sure that the dimen computation survives via e-TeX extension \dimexpr...\relax (manual section 3.5).

First box

The reasons wd=5cm-1cm fails are the following:

Internally 5cm-1cm is directly stored in a macro \beamer@colbox@wd, this is then later used to set the \hsize to:


At no point can either PGFmath or calc interact. For the latter, there needs to be a \setlength call, so


would do.

For this to work with PGFmath we could substitute to


replacing LaTeX’s (and calc’s) \setlength with \pgfmathsetlength which would make it possible to use any PGFmath option in the wd key.

Both of these solutions will fail for rounded boxes (rounded=true) because the \beamer@colbox@wd macro is used again which we could solve by also fixing another occurrences of either \beamer@colbox@wd or \bmb@width.

It might be easier to simply redefine the wd key so that it does immediately evaluate the value:


or, for calc, something like

\define@key{beamercolbox}{wd}{\setlength\pgfutil@tempdima{#1}% any "temp" is okay

Obviously this needs to be done for other keys, too, if you want to use them; in the beamercolbox namespace there are also ht, dp, leftskip and rightskip. If you use those calculations often, it might be worth it (and it also might be better to ask the developers); otherwise use the already discussed \dimexpr solution.

  • Uf! I just wanted to be sure that i wasn't doing anything wrong. In any case I'll try to understand your answer and apply in future themes. Thank you.
    – Ignasi
    Commented Oct 24, 2013 at 20:38
  • @Ignasi You weren’t doing anything wrong. The keys from the beamercolorbox environment simply aren’t setup for dimension calculation. My answer shows how one would correct that (at best in the source files directly), for a one-time problem, use \dimexpr. :) Commented Oct 25, 2013 at 19:10

You must log in to answer this question.

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