[Tex/LaTex] Embed Github readme.md in Latex

gitinputmarkdown

During my thesis I have created multiple Git-Repositories which are documented using the readme.md which GitHub uses as repository explanation. Now I would like to include those documentations into the appendix of my thesis.
What is the best way to do so?

I would prefer a solution which just links the readme.md files, so that changes get included automatically.

Best Answer

This can best be done using a Markdown-to-LaTeX-Compiler and a Makefile to build the project. Here's an example rundown of how you could proceed:

  1. Install pandoc
  2. Create a Makefile or equivalent (Batch file, script, ...) with the following content, repeating the first line for every project readme you wish to include:

    pandoc /path/to/GitHub/project/readme.md -f markdown -t latex -s -o /path/to/GitHub/project/readme.tex
    pdflatex <arguments> file.tex
    
  3. Add \include{/path/to/GitHub/project/readme} statements in your LaTeX document where applicable.

  4. Use the Makefile to build your project. It's not strictly necessary to do this after each change in the LaTeX document, only after changing/adding a GitHub project readme.

Alternatively, you could follow this answer and use pandoc in LaTeX on-the-fly. I consider this a less elegant solution, but nonetheless here's a quick rundown on how you would use this to accomplish what you want:

  1. Install pandoc
  2. Copy the preamble from the example document in the linked answer
  3. To embed Markdown files, embed them in your document like this:

    \begin{markdown}
      \input{/path/to/GitHub/project/readme.md}
    \end{markdown}
    
  4. Every time you compile the document, it should compile and embed the Markdown documents as well.