1

I have a question with regards to dynamic documents written with Stata 15. I am using the dyndoc command, you can see how it works with examples here.

Since in some of my reports there is plenty of content, I would like to include a table of content at the beginning of each file. I am not sure, but it seems to me that there is no support for anything similar with dyndoc. However, the command structure allows embedding html snippets with dd_include, including a reference to a css style sheet (see here). Therefore, I thought I could include a java or php script in a header.txt (see the previous link) and go down that path.

In the markdown language every title generated with a series of ### becomes an <h> element in the html after the dyndoc conversion. Therefore, I thought I need a script which identifies these <h> elements and creates the table. I have tried several options with java from here and with php from here. However, none of this works, and I am not even sure I am on the right path.

Is there anyone with some more experience with similar issues? I'd appreciate any help!

Erdne Htábrob
  • 819
  • 11
  • 29

1 Answers1

1

I have managed to do it, following the answer by Hasse Björk at this link.

As he describes, I included the code snippet for the java script he provides in the header.txt (see above), wrapped in <script type="text/javascript"> and the corresponding </script>. Then, in the actual markdown file which dyndoc parses I included the following line, at the beginning of the file: <nav id="toc"><strong><font size="6">Content of this section</font></strong></nav> You can format it as you wanted, but I avoided the <h> tag in order not to list the content table in the content table. I also added the formatting options suggested in the original answer to the style sheet.

Erdne Htábrob
  • 819
  • 11
  • 29