# How to use pandoc to convert markdown to readable/editable LaTex with Beamer?

I have asked this question on SO, but it didn't get any response, so I am tryin here as well, I hope it's not out of scope.

If I use this minimal example of a Markdown slide

### Slide

- A
- bulleted
- list

~~~{.cpp}
template<typename A>
class B {};
~~~

and convert it to LaTex Beamer with pandoc using pandoc -t beamer mwe.pd -o mwe.latex, I get this unreadable LaTex file

\begin{frame}[fragile]{Slide}
\protect\hypertarget{slide}{}
\begin{itemize}
\tightlist
\item
A
\item
bulleted
\item
list
\end{itemize}

\begin{Highlighting}[]
\KeywordTok{template}\OperatorTok{\textless{}}\KeywordTok{typename}\NormalTok{ A}\OperatorTok{\textgreater{}}
\KeywordTok{class}\NormalTok{ B }\OperatorTok{\{\};}
\end{Highlighting}
\end{frame}

What do I have to do to inform pandoc that I would like to use minted for code highlighting (Highlighting is a placeholder)?

Can \protect be removed? What about the weird formatting of \items?

What I expected to get from this minimal example was

\begin{frame}[fragile]{Slide}

\begin{itemize}
\item A
\item bulleted
\item list
\end{itemize}

\begin{verbatim}
template<typename A>
class B {};
\end{verbatim}

\end{frame}

or something similar to that. Even if Highlighting is a placeholder, this is practically a MWE for .md to .latex conversion, and the code in .latex is rendered unreadable by *Tok...

Option one: Make a standalone document (-s), not only the body of the document.

pandoc -s -f markdown -t beamer mwe.Rmd -o mwe.tex

Option two: use Rstudio with a YAML header like this:

---
output:
beamer_presentation:
keep_tex: yes
---

### Slide

-   A
-   bulleted
-   list

 {.cpp}
template<typename A>
class B {};


Then, using the Knit button, not only will produce the Beamer PDF, but also maintain the LaTeX version in the working directory, in case that you want to modify it directly. However, both options are the worst workflow possible, because the numerous ad hoc macros added, like \OperatorTok. Always write inrmarkdown only, or write only in plain latex from the beginning.

Well, a third option could be to make a custom pandoc template to produce a simplified export, but I left this as an exercise for advanced users.