HomeMiscellaneousPredefined macrosSymbols
User Manual UDO > The UDO syntax > Miscellaneous Index

Definitions

Like macros, definitions are user-defined placeholders. You can use them to insert special commands inside the text, especially for the destination format.

The syntax is !define [<word>] [<text>]. In contrast to macros, [<text>] will not be converted in a special way. No special characters are translated inside [<text>].

This example demonstrates how to print headlines with HTML:

!ifdest [html]
  !define H1 

!define h1

!else !define H1 !define h1 !endif [...] (!H1)A headline(!h1)

As you can see you can use definitions to insert special commands that aren't supported by UDO. UDO Release 4 offered a lot of special commands for LaTeX that you now have to simulate with the !define command:

!ifdest [tex]
  !define ff "ff
  !define lb2 \linebreak[2]
  !define nolb3 \nolinebreak[3]
!else
  !define ff ff
  !define lb2
  !define nolb3
!endif
[...]
Tell (!LaTeX) a good place
(!lb2) for breaking lines.

You can use definitions with parameters, too. Definitions with parameters are used the same way you can use macros with parameters. Definitions with parameters are a great help to expand UDO's support of a destination format.

You declare definitions like in the upper example. You can tell UDO the positions of the parameters by adding (!1), (!2) up to (!9). When you call a definition you have to write brackets ([...]) around the parameters.

In the upper example I have shown you how to make a heading for HTML. When using parameters it may look like the following example:

!ifdest [html]
  !define head 

(!1)

!else !define head (!1) !endif [...] (!head [A headline])

As you can see in this example you can write format depending commands UDO doesn't support already.

The upper LaTeX example can be defined nicer, too. If you use parameters you can provide all available LaTeX commands in one definition:

!ifdest [tex]
  !define lb \linebreak[(!1)]
!else
  !define lb (!2)
!endif
[...]
Tell (!LaTeX) a good place
(!lb [2]) for breaking lines.

In this example only one parameter is used but the non-LaTeX definition contains a second parameter. You may ask yourself why it has to be like this. Well, if you call the definition with only one parameter the second parameter is empty. When expanding the non-LaTeX definition UDO will replace the definition placeholder by empty space (because there is no second parameter, you understand?). Unfortunately you have to use this work-around when using definition with placeholders.


Hints:

  1. Characters of the text of the !define command won't be converted.
  2. Characters of the parameters you pass to the definition will be converted.
  3. UDO supports the !heading command for displaying headlines. The upper HTML example is only used for demonstration.
  4. When naming the definitions you should be cautious not to use pre-defined UDO command names like B or nl. If you don't you will get problems with bold text ((!B)) or the newline command ((!nl)).
  5. You shouldn't use too many definitions because every additional definition slows down the conversion of the source file. The maximum number of definitions is 1000.

Copyright © www.udo-open-source.org (Contact)
Last updated on May 19, 2014

HomeMiscellaneousPredefined macrosSymbols