B.1.1 How can I make plasTeX work with my complicated macros?

While plasTeX makes a valiant effort to expand all LaTeX macros, it isn’t TeX and may have problems if your macros are complicated. There are things that you can do to remedy the situation. If you are getting failures or warnings, you can do one of two things: 1) you can create a simplified version of the macro that plasTeX uses for its work, while LaTeX uses the more complicated one, or 2) you can implement the macro as a Python class.

In the first solution, you can use the \ifplastex construct to wrap your plasTeX and LaTeX versions of the macros. You can even just remove parts of the macros. See the example below.

% Print a double line, then bold the text.  
% In plasTeX, leave the lines out.
\newcommand{\mymacro}[1]{\ifplastex\else\vspace*{1in}\fi\textbf{#1}}

Depending on how complicated you macro is, you may want to implement it as a Python class instead of a LaTeX macro. Using a Python class gives you full access to all of the plasTeX internal mechanisms to do whatever you need to do in your macro. To read more about writing Python class macros, see the section 4.