HowTo Trace2UML in LaTeX

Trace2UML can be used to visualize the call of macros in LaTeX documents. This is implemented by writing the corresponding Trace2UML commands in a .seq-file while compiling the LaTeX document. Therefore macros are needed to open (close) a new outputstream and to write the desired output to the .seq-file.

LaTeX Trace2UML Macros

For the example in this article the following five macros have been used.

“Call”, “Return from” and “Create” a Macro

	\immediate\write\tracetouml{> #1}%
	\immediate\write\tracetouml{< }%
	\immediate\write\tracetouml{+ #1}

Open and Close a Write Stream

Place these macros at the beginning and end of the document respectively:


To automatically open and close, respectively, the outpustream add


to the preamble of the document.

Example Document

To demonstrate the basic idea the following LaTeX snippets show how to utilize these macros. First two new macros are defined:

  • macroA that twice calls macroB
  • macroB that prints the current date and time (provided by scrtime)
	\today, \thistime%

Next the following LaTeX code is compiled. Here macroA is called and then redefined and called a second time. Note that the outpustream is opened and closed automatically as described above.


The picture below shows the resulting sequence diagram.

! Document
0003         ~ ==> Document 
! macroA
0005  Document ==> macroA   
! macroB
0007    macroA ==> macroB   
0008    macroA <== macroB   
0009    macroA ==> macroB   
0010    macroA <== macroB   
0011  Document <== macroA   
0012  Document (!) macroA   
0014  Document ==> macroA   
0015    macroA ==> macroB   
0016    macroA <== macroB   
0017  Document <== macroA   
0018         ~ <== Document 
howto/trace2umlinlatex.txt · Last modified: 2015/05/13 16:36 by thomas
GNU Free Documentation License 1.3
Powered by PHP Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 Valid HTML5