##### 37.2.4.3 Creating a chain of macro libraries

A macro library file can include a setting for [Templates]Macros, so the chain of libraries for DITA2Go to search for macro definitions can be any length. However, all files in the chain must have distinct names; the chain stops if DITA2Go finds a repeated macro library name.

Precedence of macro definitions

In a chain of macro libraries, if the same macro appears in more than one library file but has a different definition in each file:

- A definition in a library closer in the chain to the project configuration file overrides a definition in any library farther away in the chain.
- A definition in the project configuration file overrides the final library value.
- A definition in an individual map configuration file (see §42.1 Using a different configuration for selected files) overrides a definition in the project configuration file, for that map only.

DITA2Go builds a set of macros for each DITAmap file in your project by starting with the most specific macro definitions: those in the mapfile.ini configuration file, if there is one. Next come macro definitions in your project configuration file.

Next, if mapfile.ini includes a value for [Templates]Macros, definitions in the referenced macro library (and any additional libraries chained to it) are applied. If mapfile.ini does not reference a macro library, next come definitions in any macro library referenced by the project configuration file; then on up the chain from that library.

In other words, a chain of macro libraries is applied to mapfile.ditamap either from mapfile.ini (preferentially) or from the project configuration file, but not from both. In either case, definitions from a chain of macro libraries are applied after macro definitions from the project configuration file, which are applied after definitions from the chapter configuration file. For the same macro with different definitions in different configuration files or macro libraries, the definition in the most specific file takes precedence.

Previous Topic: 37.2.4.2 Creating a file-specific macro library

Next Topic: 37.3 Using macro variables

Parent Topic: 37.2.4 Including macro definitions in your own macro library

Sibling Topics:

37.2.4.1 Creating a macro library

37.2.4.2 Creating a file-specific macro library