formatbeforehook
formatbeforehook
Function prototype:
hook (COMMAND, want_final)
Synopsis
Use with:
add_hook(hookname, func[, prepend])
remove_hook(hookname, func)
where hookname is formatbeforehook.
This hook is called immediately before the first formatting pass when printing, previewing, or formatting a document. The want_final flag indicates that the command that caused formatting (print, preview, format, and so on) was requested to do as many formatting passes as necessary to produce the a final version of the document. For example, if the command that started formatting was
preview allpasses
formatbeforehook will be invoked with the command parameter set to preview and the want_final parameter set to 1 before each formatting pass.
This hook is allowed to modify the document. When modifying the document, generated text is recalculated and the .tex file is rewritten. This hook cannot be used to invoke formatting.
Returning true writes a new .tex file. Returning false allows a .tex file write but does not force the write. Returning true is appropriate if the hook changes state in such a way that it would affect the result of system functions called from the stylesheet. Typically, a .tex file is rewritten only if the document instance changes or if generated text must be recalculated. The hook assumes formatting is being done on current_doc().
Arguments
• command is a string specifying the command requesting formatting: format, preview, or print.
• want_final is 1 if all formatting passes are specified. Otherwise, want_final is 0.