# Add Markdown Citations using Pandoc

I am going through a process of converting all our code documentation from LaTeX to Markdown. I figured that my best bet was to use Pandoc. We have developed our own flavor of Markdown so I will need to go in and edit by hand some of the freshly converted markdown.

I am having trouble producing proper citations within my markdown. The current command I am using seems to be "hardcoding" the citations in without markdown short cuts (ie. (Hammond et. all 2015) vs [@cite:Hammond]). I have the .bib files. Is there a way to make this work?

Code I am currently running to convert from LaTeX to MD

pandoc --ascii -f latex -t gfm --filter=pandoc-citeproc -o test.md input.tex

Code I have tested but still doesn't work

pandoc -s -V biblio-files=../../../../../../doc/content/bib/*.bib --filter=pandoc-citeproc -f latex -t gfm -o test.md input.tex

How can I get it to produce a dynamic markdown citation instead of hardcoding it in?

### Sample TeX File

\documentclass[11pt]{article}
\usepackage{cite}

\begin{document}

\title{My Article}
\author{Nobody Jr.}
\date{Today}
\maketitle

Blablabla said Nobody ~\cite{Nobody06}.

\bibliography{name}{}
\bibliographystyle{plain}
\end{document}


### Sample Bib File

@misc{ Nobody06,
author = "Nobody Jr",
title = "My Article",
year = "2006" }


### Sample Output Markdown File

Blablabla said Nobody  (Jr 2006).

<div id="refs" class="references">

<div id="ref-Nobody06">

Jr, Nobody. 2006. “My Article.”

</div>

</div>


### What I want

Blablabla said Nobody [@Nobody06].

• Can you share more details about what exactly you are doing? Would it be possible to create a short example .tex document (an MWE: tex.meta.stackexchange.com/q/228/35864) and show the resulting .md file? – moewe Feb 12 at 19:25
• @moewe See my above edits. Not quite sure what more there is to explain. The way I'm currently converting it is hardcoding the citations in, but I want it to output the markdown syntax for citations like how it does for all images and tables. – dylanjm Feb 12 at 19:43
• Does gfm support citations? Playing around with pandoc.org/try/… suggests that pandoc --from latex --to markdown gives the desired output, but pandoc --from latex --to gfm does not. – moewe Feb 12 at 19:50
• That does work like how I want it, but now I've lost support to correctly render my markdown tables and images. I'm trying to convert with the least amount of manual work as possible but short of actually creating a PR to submit our flavor of markdown as a pandoc option IDK if it's possible to do what I really want. – dylanjm Feb 12 at 20:05
• Sorry, that's all I can say. I have no idea about pandoc. But if gfm has no official support for citations it is not at all unreasonable of pandoc to export the citation as hard-coded text. As long as pandoc does not allow you to cherry-pick bits of markdown syntax you seem to be caught between the devil and the deep blue sea. – moewe Feb 12 at 20:08

I found an answer thanks to @moewe's help. Apparently Github Flavored Markdown does not support short-linking citations but pandoc's own markdown does. A 2nd problem arose, in that, pandoc's markdown does not support pipe_tables by default. Running the below code gave me in text citations and also played well with all the other Markdown requirements I needed:
pandoc --ascii -f latex -t markdown-multiline_tables-simple_tables --atx-headers -o test.md test.tex