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

Table of Contents

Next: , Previous: Index entries, Up: Markup


11.6 Macro replacement

You can define text snippets with

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

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

These references, called macros, can be inserted anywhere Org markup is recognized: paragraphs, headlines, verse blocks, tables cells and lists. They can also be used in keywords accepting Org syntax, e.g., #+CAPTION, #+TITLE, #+AUTHOR, #+DATE and some others, export back-end specific, ones.

In addition to user-defined macros, a set of predefined macros can be used:

{{{title}}}
{{{author}}}
{{{email}}}
These macros are replaced with the information available at the time of export.
{{{date}}}
{{{date(FORMAT)}}}
{{{time(FORMAT)}}}
{{{modification-time(FORMAT)}}}
These macros refer to the #+DATE keyword, the current date, and the modification time of the file being exported, respectively. FORMAT should be a format string understood by format-time-string. Note that FORMAT is an optional argument to the {{{date}}} macro, and that it will only be used if #+DATE is a single timestamp.
{{{input-file}}}
This macro refers to the filename of the exported file, if any.
{{{property(PROPERTY-NAME)}}}
{{{property(PROPERTY-NAME,SEARCH-OPTION)}}}
This macro returns the value of property PROPERTY-NAME in current entry. If SEARCH-OPTION (see Search options) refers to a remote entry, it will be used instead.

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

Macro expansion takes place during the very beginning of the export process.


Footnotes

[1] Since commas separate arguments, commas within arguments have to be escaped with a backslash character. Conversely, backslash characters before a comma, and only them, need to be escaped with another backslash character.