I am writing a project report in markdown. Use LaTeX inside the markdown to write formulas. Then I convert the markdown file to PDF with pandoc. All works like a charm.
But, I would like to include the pseudocode of an algorithm in this format: 
I have seen in this post Write pseudo code in latex how to do the same in pure LaTeX, but the code provided fails miserably while pandoc tries to interpret to render the PDF. This is the error code:
$ pandoc a.md -o a.pdf
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.60 \documentclass
pandoc: Error producing PDF
Anybody knows if this can be done? I can always write the pseucode in Overleaf.com and export it as image, but I would prefer to maintain all in the markdown file. THANKS!
BTW: The workflow is based in OSX (mactex 2018 + pandoc)
