title: Pandoc: use variables in custom latex preamble
body: <p>I have the file test.md which contains:</p>
  
  <pre><code>---
  footertext: some text for the footer
  headertext: this is in the header
  ---
  
  here is the text body.
  </code></pre>
  
  <p>And the file format.tex which contains:</p>
  
  <pre><code>\usepackage{fancyhdr}
  \pagestyle{fancy}
  \fancyhead[L]{$headertext$}
  \fancyfoot[L]{$footertext$}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  \setlength{\headsep}{0.25in}
  </code></pre>
  
  <p>I run the command:</p>
  
  <pre><code>pandoc -H format.tex test.md -o test.pdf
  </code></pre>
  
  <p>You can see what I want to do. I am trying to get the text "this is in the header" to show up in the header, but it does not, it only shows the string "headertext" (same problem for footer).</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit: OK, I think I understand. Apparently variables are only available in templates, not in included begin or end code blocks (like I am using), or in the md itself. So new question: Why is this? It is unintuitive, inconvenient, and poorly documented. </p>