0

I'm writing a shell script (.sh) to:

  1. Convert a markdown file (README.md) to HTML
  2. Convert a HTML file to latex.
  3. Convert a latex file to PDF.

The shell script uses MultiMarkdown v6 (by Fletcher Penney) for step 1-2 and "pdflatex" for step 3. The files are generated and formatted automatically.

The PDF pages are numbered, however, the pages in the table of content are not and question marks appear in the toc.

I included the metadata at the very top of the README.md. The script uses metadata to generate the latex file. I created the toc using the usual method for Github readme.md.

MMDv6 provides the "{{TOC}} function" (I did not use it). I could not get my head around this function so I just created a toc using the method I mentioned above.

MultiMarkdown User's Guide has a small section about toc (https://fletcher.github.io/MultiMarkdown-6/MMD_Users_Guide.html#tableofcontents).

Useful info about MMD & Latex

(https://github.com/fletcher/MultiMarkdown/wiki/MultiMarkdown-and-LaTeX)

My table of content has the following structure:

Table of Contents
=================

<!--ts-->
   1. [Abstract](#Abstract)
   2. [Table of Contents](#Table-of-Contents)
   3. [System Installation](#System-Installation)
   4. [System Architecture](#System-Architecture)

etc...

The script runs well, however, I would expect page numbers in the toc. The toc on the PDF looks like:

  1. Abstract (??)
  2. System Installation (??)
  3. System Architecture (??)

where (??) corresponds to the page number. How can I fix this? Do you have any suggestion? Thanks

csi21
  • 1
  • 4
  • For MMD you manually insert `{{TOC}}` at the location where you want the table of contents to exist and MMD will autogenerate one and insert it at that location. Go head and try it by adding the text `{{TOC}}` on a line by itself at any location in the document. Of course, that won't address your page number issue. – Waylan Jul 25 '19 at 18:55
  • Any reason why you aren't using Pandoc, which can go directly from Markdown [to PDF](https://pandoc.org/MANUAL.html#creating-a-pdf) without all the intermediary steps? Pandoc even supports `markdown_mmd` as an [input format](https://pandoc.org/MANUAL.html#general-options) if you need MMD specific features. – Waylan Jul 25 '19 at 19:03
  • Thank you for you help! I was aware of Pandoc, however, for the work I am currently doing I also need a latex file. I inserted {{TOC}} before publishing this post but only the word "Content" appeared. Now I realise a README.toc file was saved outside the folder where the .tex file was generated. Clearly I am doing something wrong! – csi21 Jul 25 '19 at 23:14
  • Yes it did work!! Thanks! – csi21 Jul 25 '19 at 23:27

0 Answers0