mdframed icon indicating copy to clipboard operation
mdframed copied to clipboard

Bugfix: Use font option to set font family

Open heckej opened this issue 1 year ago • 3 comments

Problem

When the option font exists (either by setting the option in an mdframed environment or by setting it as a document option), the value of this option is printed before every mdframed environment.

Solution

This commit passes the font option to the command \fontfamily and applies the font to the environment by calling the command \selectfont.

Note

Because this code is executed inside a block surrounded by \begingroup and \endgroup, the font family is only applied to the text inside this block.

heckej avatar Apr 01 '23 16:04 heckej

Perhaps font=<font family> is just a wrong use.

It's unclear whether font option accepts a font family or one or more font commands (like \bfseries), but all other font options frametitlefont, subtitlefont, subsubtitlefont, and theoremtitlefont accept font commands (like \bfseries) rather than font families.

https://github.com/marcodaniel/mdframed/blob/c4d24240c0c27e4d44262830e03dce0b0861a944/mdframed.dtx#L2555-L2556 https://github.com/marcodaniel/mdframed/blob/c4d24240c0c27e4d44262830e03dce0b0861a944/mdframed.dtx#L2562 https://github.com/marcodaniel/mdframed/blob/c4d24240c0c27e4d44262830e03dce0b0861a944/mdframed.dtx#L2582-L2583

muzimuzhi avatar Apr 02 '23 13:04 muzimuzhi

I agree that font=<font family> may be a wrong use for mdframed. To provide some context: I am using a document class which in fact expects font=<font family> as an option. When using an mdframed environment, that font family name is printed before the environment, which is obviously not the goal. The documentation is not clear about the goal either: https://github.com/marcodaniel/mdframed/blob/c4d24240c0c27e4d44262830e03dce0b0861a944/mdframed.dtx#L921-L923 but the related options indeed suggest how it could be used.

Perhaps a better solution would be to ignore document class options, such that no such conflicts arise. Is there a way to avoid this type of conflicts between environment options and document class options?

heckej avatar Apr 03 '23 14:04 heckej

In preamble, use \mdfsetup{font=} to clear font?

muzimuzhi avatar Apr 03 '23 18:04 muzimuzhi