This is the official manual for the latest Org-mode release.

Table of Contents

Next: , Previous: Include files, Up: Exporting


12.5 Macro replacement

Macros replace text snippets during export. This is a macro definition in Org:

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

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

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:

{{{title}}}
{{{author}}}
{{{email}}}
Org replaces these macro references with available information at the time of export.
{{{date}}}
{{{date(FORMAT)}}}
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.
{{{time(FORMAT)}}}
{{{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.
{{{input-file}}}
This macro refers to the filename of the exported file.
{{{property(PROPERTY-NAME)}}}
{{{property(PROPERTY-NAME,SEARCH-OPTION)}}}
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.

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.


Footnotes

[1] 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.