Next: , Previous: , Up: Exporting   [Contents][Index]

12.5 Macro replacement

Macros replace text snippets during export. Macros are defined globally in org-export-global-macros, or document-wise with the following syntax:

#+MACRO: name   replacement text $1, $2 are arguments

which can be referenced using {{{name(arg1, arg2)}}}128.

Org recognizes macro references in following Org markup areas: paragraphs, headlines, verse blocks, tables cells and lists. Org also recognizes macro references in keywords, such as #+CAPTION, #+TITLE, #+AUTHOR, #+DATE, and for some back-end specific export options.

Org comes with following pre-defined macros:


Org replaces these macro references with available information at the time of export.


This macro refers to the #+DATE keyword. FORMAT is an optional argument to the {{{date}}} macro that will be used only if #+DATE is a single timestamp. FORMAT should be a format string understood by format-time-string.

{{{modification-time(FORMAT, VC)}}}

These macros refer to the document’s date and time of export and date and time of modification. FORMAT is a string understood by format-time-string. If the second argument to the modification-time macro is non-nil, Org uses vc.el to retrieve the document’s modification time from the version control system. Otherwise Org reads the file attributes.


This macro refers to the filename of the exported file.


This macro returns the value of property PROPERTY-NAME in the current entry. If SEARCH-OPTION (see Search options) refers to a remote entry, that will be used instead.


This macro implements custom counters by returning the number of times the macro has been expanded so far while exporting the buffer. You can create more than one counter using different NAME values. If ACTION is -, previous value of the counter is held, i.e. the specified counter is not incremented. If the value is a number, the specified counter is set to that value. If it is any other non-empty string, the specified counter is reset to 1. You may leave NAME empty to reset the default counter.

The surrounding brackets can be made invisible by setting org-hide-macro-markers non-nil.

Org expands macros at the very beginning of the export process.



Since commas separate the arguments, commas within arguments have to be escaped with the backslash character. So only those backslash characters before a comma need escaping with another backslash character.

Next: , Previous: , Up: Exporting   [Contents][Index]