---
documentclass: report
classoption: twoside
fontsize: 12pt
output:
pdf_document:
latex_engine: xelatex
keep_tex: true
header-includes: |
\usepackage{geometry}
\usepackage{tikz}
\newcommand{\zero}{\centerline{\tikz{\node[circle, fill=gray, minimum size=0.4\linewidth] {};}}}
---
\zero
I am wondering why in the tex file I am not getting
\begin{document}
\zero
\end{document}
instead I get the full code
\begin{document}
\centerline{\tikz{\node[circle, fill=gray, minimum size=0.4\linewidth] {};}}
\end{document}
\newcommnadare expanded when exported. Not sure why, because this is exactly what LaTeX will also make, but if this is a problem, note that macros with\defare not expanded. However, you must be aware that careless use of\defcould have unexpected consequences. – Fran Dec 21 '20 at 11:35