If you do inject arbitrary LaTeX into the output stream you will probably need to use the techniques found in the section called “Debugging your Style”.