beamer icon indicating copy to clipboard operation
beamer copied to clipboard

Unintuitive behaviour of \usebeamerfont

Open ghost opened this issue 7 years ago • 12 comments

The following example document gives a tiny 3rd line while I would expect a Huge one. Why? If this is not a bug: Is there any way to prevent/change this behavior? I would like to apply the "caption name" font settings only, w/o applying the "caption" font settings as well.

\documentclass{beamer}
\setbeamerfont{caption}{size=\tiny}

\begin{document}
\begin{frame}
\par
{\tiny Some tiny text}\par
{\Huge Some Huge text}\par
{\Huge\usebeamerfont{caption name}Some Huge text!?}\par
\end{frame}
\end{document}

ghost avatar May 01 '18 16:05 ghost

This is by-design: caption name inherits from caption:

\setbeamerfont{caption}{size=\small}
\setbeamerfont{caption name}{parent={structure,caption}}

(base/themes/font/beamerfontthemedefault.sty).

josephwright avatar May 01 '18 16:05 josephwright

Ok, and is there a clean/documented way to apply the "caption name" settings without applying the "caption" (and "structure") settings, i.e. disabling the "parent=" feature?

Currently I take over the "caption" and "caption name" settings to my caption package when \usepackage{caption} is used with beamer. Unfortunately there is a bug in my implementation I would like to fix. (If there is no proper way to do so I would be forced to remove that feature from my caption package.) See also: https://github.com/axelsommerfeldt/caption/issues/4

ghost avatar May 01 '18 17:05 ghost

Just answered:

https://github.com/axelsommerfeldt/caption/issues/4#issuecomment-385733770

ghost avatar May 01 '18 17:05 ghost

@samcarter8 Your solution is sub-optimal since this would drop user settings of \setbeamerfont{caption name}{parent=...} as well. But since this is better than the old behavior (and better than dropping this feature altogether) I could live with it.

However, IMHO a solution which drops "parent=caption" only would be ideal.

And one follow-up question to https://github.com/josephwright/beamer/issues/476#issuecomment-385722933:

Why is it pre-defined as

\setbeamerfont{caption}{size=\small}
\setbeamerfont{caption name}{parent={structure,caption}}

and not as

\setbeamerfont{caption}{parent=structure,size=\small}
\setbeamerfont{caption name}{parent=caption}

?

ghost avatar May 01 '18 17:05 ghost

This questions can probably only be answered by the author, but I imagine the reason is

  • be symmetric to the colour definition. Only the label and not the caption text inherits the blue colour
  • structure in beamer is traditionally something to structure things, a bit like a headline (since sections etc are not allowed within the frame). If someone decided to make these structural elements more prominent, e.g. by using bold or bigger font, the caption label should also be bold/bigger, but not the caption text. Similar for itemize/enumeration/description where the label inherits from structure, but not the body text.

ghost avatar May 01 '18 18:05 ghost

And yes, setting the caption name font to empty is really suboptimal.

ghost avatar May 01 '18 18:05 ghost

Thanks for your explanation, this makes sense to me now. But it leaves me with a dilemma:

If I use \setbeamerfont{caption name}{parent=structure}\usebeamerfont{caption name} within my caption package, I would overwrite a potential \setbeamerfont{caption name}{parent=caption} set by the user who would like to drop the structure settings for the caption labels.

So it seems I need some kind of \clearbeamerfont{caption} (which clears all "caption" settings) instead so parent=caption does not make any harm to the/additional caption package options.

BTW: I have found:

\setbeamercolor{caption}{}
\setbeamercolor{caption name}{parent=structure}

But I would had expected:

\setbeamercolor{caption}{}
\setbeamercolor{caption name}{parent={structure,caption}}

This does not seem to be consistent to me.

ghost avatar May 01 '18 18:05 ghost

First the easy answer: \setbeamercolor{caption name}{parent={structure,caption}} is the same as \setbeamercolor{caption name}{parent={structure}}, because caption colour is empty by default. My guess: it should really be \setbeamercolor{caption name}{parent={caption,structure}} but up to know It made big difference.

ghost avatar May 01 '18 18:05 ghost

I just found \clearbeamerfont, it's spelled \setbeamerfont*.

So the only question left is why the "caption" and "caption name" color is pre-defined inconsistently with the "caption" and "caption name" font.

ghost avatar May 01 '18 18:05 ghost

Concerning the font dilemma: I have to admit I don't fully understand what the caption/subcaption packages are doing, but would it be possible to simply format the subcaption in the same way as the caption? If I understand the caption package correctly, it actually used the beamer template for captions, thus using the caption name and caption font for the label and the text respectively. Can't the subsection package do the same?

Or would help to define separate beamer templates for the subcaption and two new font templates?

ghost avatar May 01 '18 18:05 ghost

Besides the fact that the caption colour is not set per default, \setbeamercolor{caption name}{parent={caption,structure}} would in reality basically always be the same as \setbeamercolor{caption name}{parent={structure}} because structure is such a key colour to every beamer presentation that I have yet to see one where the colour is not set, thus it would always overwrite the caption colour.

ghost avatar May 01 '18 18:05 ghost

The same LaTeX code is used for typesetting the captions and sub-captions. The problem is that the sub-caption package was adding font+=small (and is now adding font+=smaller instead) to typeset the sub-captions smaller than the main captions by default. So the sub-caption was typeset with beamer settings plus \small. And the label was typeset with beamer settings as well, but because of parent=caption the \small was overwritten for the caption label by \setbeamerfont{caption}{size=\tiny}, so the sub-caption label and the sub-caption text were typeset with different font sizes (label=tiny but text=small).

But maybe we should discuss this at https://github.com/axelsommerfeldt/caption/issues/4

ghost avatar May 01 '18 18:05 ghost