josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.44k stars 143 forks source link

Unintuitive behaviour of \usebeamerfont #476

Open ghost opened 6 years ago

ghost commented 6 years ago

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}
josephwright commented 6 years ago

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

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

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

ghost commented 6 years ago

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 commented 6 years ago

Just answered:

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

ghost commented 6 years ago

@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 commented 6 years ago

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

ghost commented 6 years ago

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

ghost commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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