pandoc/test/command/macros.md
John MacFarlane 9e6b9cdc5f LaTeX reader: Support \let.
Also, fix regular macros so they're expanded at the
point of use, and NOT also the point of definition.
`\let` macros, by contrast, are expanded at the
point of definition.  Added an `ExpansionPoint`
field to `Macro` to track this difference.
2017-08-07 13:38:15 -07:00

554 B

% pandoc -f markdown+latex_macros -t markdown
\newcommand{\my}{\phi}
$\my+\my$
^D
\newcommand{\my}{\phi}
$\phi+\phi$
% pandoc -f markdown-latex_macros -t markdown
\newcommand{\my}{\phi}
$\my+\my$
^D
\newcommand{\my}{\phi}
$\my+\my$

\let macros should be expanded at point of definition, while \newcommand macros should be expanded at point of use:

% pandoc -f latex -t latex
\let\a\b
\newcommand{\b}{\emph{ouk}}
\a
^D
\b
% pandoc -f latex -t latex
\newcommand{\a}{\b}
\newcommand{\b}{\emph{ouk}}
\a
^D
\emph{ouk}