0

EDIT: Answer found here: How to check if a macro value is empty or will not create text with plain TeX conditionals?

Consider the following code snippet from a .sty file

\makeatletter
\newcommand{\Snippet}[3]{% 
    \@namedef{csh#1}{\sremA{#2}{#3}}%
    \@namedef{bea#1}{\sremB{#2}{#3}}%
}%

\newcommand{\sremB}[2]{
    \begin{frame}
    \frametitle{#1}
    \begin{shadedrem}
        #2
    \end{shadedrem} 
    \end{frame}
}

I want to change this code to

\makeatletter
\newcommand{\Snippet}[4]{% 
    \@namedef{csh#1}{\sremA{#2}{#3}}%
    \@namedef{bea#1}{\sremB{#2}{#3}{#4}}%
}%

\newcommand{\sremB}[3]{
    \begin{frame}
    \frametitle{#1}
    \begin{shadedrem}
        #2
    \end{shadedrem} 
    \end{frame}
%%% Pseudo code 
if #3 is not empty then
( here I will process text in #3 )
endif
}

I have the following questions. How to code the "if #3 is not empty then"?, and is it possible to create a command where the last argument is optional? Such that

\cmd{#1}
\cmd{#1}{#2}

both work?

0 Answers0