Handling ``order-sensitive'' Commands
Some commands need to be passed to LATEX, but using the &process_commands_in_tex subroutine gives incorrect results. This may occur when the command is ``order-sensitive'', using information such as the value of a counter or a boolean expression (or perhaps requiring a box to have been constructed and saved). Try using the &process_commands_inline_in_tex subroutine instead. Commands declared this way are first ``wrapped'' within a dummy environment, which ensures that they are later processed in correct order with other environments and order-sensitive commands.


Other commands may need to be passed to LATEX, not to create an image themselves, but to affect the way subsequent images are created. For example a color command such as \color{red} should set the text-colour to `red' for all subsequent text and images. This must be sent to LATEX so that it is processed at exactly the right time; i.e. before the first image required to be `red' but following any images that are not intended to be affected by this colour-change.
The subroutine process_commands_nowrap_in_tex is designed specifically to meet such requirements.


Commands can be order-sensitive without having to be passed to LATEX. Indeed even if a Perl subroutine has been carefully written to process the command, it may still give wrong results if it is order-sensitive, depending on the values of counters, say. To handle such cases there is the &process_commands_wrap_deferred subroutine. This also ``wraps'' the command within a dummy environment, but when that environment is processed the contents are not sent to LATEX, as in the previous case. All of the standard LATEX commands to change, set or read the values of counters are handled in this way.