Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plain frame command another instance of frame? #11

Closed
ghost opened this issue Dec 2, 2014 · 6 comments
Closed

Make plain frame command another instance of frame? #11

ghost opened this issue Dec 2, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Dec 2, 2014

If the \plain{[title]}{body} command for dark frames matched Beamer frame syntax, it would allow Beamer exporters like emacs org-mode to reference it using existing templates.

I can come up with something but I need a little bit of a sketch on defining frames in LaTeX style files as I've never done it before.

@ghost ghost changed the title Make plain frame command another instance of frame? Make plain frame command another instance of frame? Dec 2, 2014
@matze
Copy link
Owner

matze commented Dec 2, 2014

If the \plain{[title]}{body} command for dark frames matched Beamer frame syntax, it would allow Beamer exporters like emacs org-mode to reference it using existing templates.

Sounds like a good idea!

I've never done it before.

Me neither. So do you want to continue or should I investigate at some point?

@ghost
Copy link
Author

ghost commented Dec 4, 2014

I can at least provide some extra information after the presentation I'm using the theme for is done :)

@matze matze modified the milestone: Version 1.0 Jun 17, 2015
@rchurchley
Copy link
Contributor

What is meant by "Beamer frame syntax"? If you just want

\begin{plainframe}{...title...}
    ...
\end{plainframe}

we should be able to accomplish this using \newenvironment instead of \newcommand. Or am I missing something?

@rchurchley
Copy link
Contributor

I've finally done some research into this long-standing issue. I believe I originally misunderstood @talexand's request; by "matching frame syntax", he means implementing the standout plain slides as an optional argument to frame.

\begin{frame}[standout]
  Questions?
\end{frame}

(Obviously, we couldn't use plain as the argument, as this already exists in Beamer. I've called the option standout for now since I couldn't think of anything better, but I'd welcome other ideas for what to call it.)

As I understand it, doing this would allow users of emacs org-mode to generate the above frame using something like the following input. (Note: I have not actually tested it.)

* A standout slide                    :B_ignoreheading:
:PROPERTIES:
:BEAMER_opt: standout
:END:
    Questions?

Advantages

Moving to an optional frame argument offers a couple mild advantages in addition to emacs org-mode compatibility.

  • The syntax is more consistent with other frames.
  • It could make it very slightly easier to adapt a presentation to or from ᴍᴇᴛʀᴏᴘᴏʟɪs.
  • We could implement the new option in the inner theme, making it possible to use independently of the font and color themes. (For some reason, I feel more comfortable defining a new frame option in the inner theme than a new command.)

Disadvantages

The main disadvantage of this proposal is that I don't see a way of implementing the allsmallcaps and allcaps options of titleformat plain. This can be mitigated by keeping \plain{...} as a shortcut for \begin{frame}[standout]{#1}\metropolis@plaintitleformat{#2}\end{frame}

Implementation

To implement the optional argument, we just have to move all the code from \plain to a block that is executed when the standout option is called. (See the keyval package for details.) Most of it is straightforward; we begin a group, change the colors and fonts, and set a \centering alignment.

(This code is all executed before the frame is fully set up, so adding a \MakeLowercase here for titleformat plain=allsmallcaps would break the frame rather than applying to its contents.)

\providebool{metropolis@standout}
\define@key{beamerframe}{standout}[true]{%
  \booltrue{metropolis@standout}
  \begingroup
    \setkeys{beamerframe}{c}
    \setkeys{beamerframe}{noframenumbering}
    \ifbeamercolorempty[bg]{palette primary}{
      \setbeamercolor{background canvas}{
        use=palette primary,
        bg=-palette primary.fg
      }
    }{
      \setbeamercolor{background canvas}{
        use=palette primary,
        bg=palette primary.bg
      }
    }
  \centering
  \usebeamercolor[fg]{palette primary}
  \usebeamerfont{plain title}
}

Then, we just need to end the group after the standout slide is finished in order to restore the colours and fonts for the rest of the presentation. Unfortunately, the obvious solution — \AfterEndEnvironment{frame}{...}doesn't work. I've therefore chosen to add the \endgroup to \beamer@reseteecodes, which I believe is run exactly once at the end of each slide. I'm not 100% confident of this, though, so if we choose to go this route we'll need to test extensively to make sure there are no unintended consequences.

\apptocmd{\beamer@reseteecodes}{%
  \ifbool{metropolis@standout}{
    \endgroup
    \boolfalse{metropolis@standout}}{}
}

Discussion

The primary question we should answer here is do we want to implement plain slides as an optional argument to frame? (Presumably we will still support the \plain syntax as well.) If the answer is "no" we can just close this issue; if it's "yes", I will pull request the above implementation and we can discuss there if it works or can be improved.

@ghost
Copy link
Author

ghost commented Mar 2, 2016

Thanks for looking into this further. I haven't been able to get to this but I still think it would be a good feature.

@matze
Copy link
Owner

matze commented Mar 3, 2016

The primary question we should answer here is do we want to implement plain slides as an optional argument to frame?

Tough call. However, for the sake of the listed advantages I'd support your proposal for the standout option. In the long run (i.e. for 2.0), I'd deprecate the \plain command though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants