4.1 Defining Macros in LaTeX

Defining macros in LaTeX using plasTeX is no different than the way you would normally define you macros; however, there is a trick that you can use to improve you macros for plasTeX, if needed. While plasTeX can handle fairly complicated macros, some macros might do things that don’t make sense in the context of a plasTeX document, or they might just be too complicated for the plasTeX engine to handle. In cases such as these, you can use the \ifplastex construct. As you may know in TeX, you can define your own \if commands using the \newif primitive. There is an \if command called \ifplastex built into the plasTeX engine that is always set to true. In you document, you can define this command and set it to false (as far as LaTeX is concerned) as follows.

\newif\ifplastex
\plastexfalse

Now you can surround the portions of your macros that plasTeX has trouble with, or even write alternative versions of the macro for LaTeX and plasTeX. Here is an example.

\newcommand{\foo}[1]{
    \ifplastex\else\vspace*{0.25in}\fi
    \textbf{\Large{#1}}
    \ifplastex\else\vspace*{1in}\fi
}

\ifplastex
    \newenvironment{coolbox}{}{}
\else
    \newenvironment{coolbox}
        {fbox\bgroup\begin{minipage}{5in}}
        {\end{minipage}\egroup}
\fi