Site icon 峰哥分享

Use markdown with latex using pandoc

Recently, I am writing a paper. I have written a few paragraphs with markdown. And I save my markdown files as Azure Devops wiki pages. To avoid converting all these markdown files into latex files, I am looking for a solution to reuse all these markdown files in latex. I still would like to use latex because I don’t know how to manage IEEE double columns format and bibliography with markdown. Then I found that pandoc may fit my purpose.

The template I used is from here

https://github.com/lauritzsh/pandoc-markdown-template

I don’t want to install pandoc on my computer, so I chose to use a docker version. Run the following command inside the folder with your template files.

Note that, if you are using docker toolbox on windows, you have to run the command in Docker Quickstart Terminal. Also the template files must be under a folder or sub-folder of %userprofile%. Otherwise, the volume mapping will not work.

docker run -v `pwd`:/data --rm -it --entrypoint sh pandoc/latex

Once you enter the shell, you can install bash by apk add bash

you can then use whatever terminal tool to run the following command to enter the bash shell

#eloquent_lichterman is the container name
docker exec -it eloquent_lichterman bash

You can run apk add make to install make. But the Makefile is not working in my case. And I also tried a bash file, same issue.

So I end up with run the command directly in the shell.

pandoc --from markdown --to latex --template template.tex --out report-bib.pdf --pdf-engine xelatex --bibliography biblio.bib --csl style.csl dynamic/ruby.md dynamic/python.md dynamic/javascript.md static/java.md static/csharp.md functional/haskell.md functional/fsharp.md bibliography.md

This works.

Exit mobile version