josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.41k stars 142 forks source link

Advise (or at least document) the new way of creating document commands and environments #828

Closed dbitouze closed 1 year ago

dbitouze commented 1 year ago

Maybe it's time to advise (or at least document) the new way of creating document commands and environments. For instance, page 85 (of the current (3.68)) documentation, the example:

\newcommand<>{\makered}[1]{{\color#2{red}#1}}

could be replaced by:

\NewDocumentCommand{\newmakered}{ d<> m }{{\color<#1>{red}#2}}

More generally, the syntax:

\newcommand<>{⟨command name⟩}[⟨argument number⟩][⟨default optional value⟩]{⟨text⟩}

could be replaced by:

\NewDocumentCommand{⟨command name⟩}{ d<> ⟨arg spec⟩}{⟨text⟩}

with the description changed accordingly.

samcarter commented 1 year ago

There is already an example with \NewDocumentCommand on p. 86

https://github.com/josephwright/beamer/blob/7ea4816f890851abb425b972ca29b5c0b8bfa05a/doc/beamerug-overlays.tex#L548-L553

dbitouze commented 1 year ago

Oooops, sorry for the noise!

samcarter commented 1 year ago

For the time being, I'd also favour using beamer's adapted version of \renewcommad<> etc. over \NewDocumentCommad as the later does not retain the original definition.

\documentclass{beamer}

\usepackage{mdframed}

\renewenvironment<>{mdframed}[1][]{%
  \begin{originalmdframed}[#1]\color{red}%
}{%
  \end{originalmdframed}%
} 

\begin{document}
\begin{frame}
    \begin{mdframed}
        test
    \end{mdframed}
\end{frame}
\end{document}