# Could you put {{TOC}} in Metadata?

#### Kolen

14 Mar, 2015 06:07 AM

Hi, I found that in the latest version of MMD, {{TOC}} is added. It is a very nice feature. But currently very cumbersome to be included to support both HTML and LaTeX. (I mean it is support LaTeX already but I want the native ToC from LaTeX.)

One way I do it currently is:

<!--
\setcounter{tocdepth}{5}
\tableofcontents
\begin{comment}
-->

{{TOC}}
<!--\end{comment}-->


Such that the HTML will skip the LaTeX command and the LaTeX will skip the TOC generated by mmd.

What I want to suggest is to promote it to a metadata field. (I am not sure if it can be done already since the documentation didn't mention.), implemented in a similar way as the base header level such that it has variants. In this way I can activate TOC in HTML only, and use LaTeX Input to include the \tableofcontents. It is also useful in file transclusion since the transcluded file ignores the metadata, and hence I won't have repeated metadata in the result.

Another suggestion is to replace {{TOC}} automatically with \tableofcontents when converting into LaTeX. And possibly define {{TOC}}[5] to mean\setcounter{tocdepth}{5} \tableofcontents which can also be used for HTML output.

1. Support Staff Posted by fletcher on 14 Mar, 2015 01:13 PM

Between existing features, there is already the ability to do this -- you can use file transclusion to specify {{TOC}} only in certain formats, or the approach that you used above.

In general, I don't want to make MMD any more complex than it already is, but rather make use of the current features to implement customizations.

2. fletcher closed this discussion on 14 Mar, 2015 01:13 PM.

3. Kolen re-opened this discussion on 14 Mar, 2015 10:39 PM

4. Posted by Kolen on 14 Mar, 2015 10:39 PM

Thanks. The file transclusion feature is a nice suggestion.

However, it doesn't quite work for me. It will turn my .tex file having \ into \textbackslash

Another problem is I don't understand why when I use .*, transclusion to .tex works fine, but not .html. Another related question is I don't know what to put in the .html.

This?

**Table of Contents**

{{TOC}}


But I'm not sure if it will treat it like mmd code or html code...

In general, I find the file transclusion feature intriguing. But the documentation on this is very limited and vague. I think it would be better if, say, it has some example in the mmd gallery.

5. Support Staff Posted by fletcher on 16 Mar, 2015 01:15 PM

File transclusion is very simple -- it replaces {{foo}} with the
contents of the file to create a single MMD document. That's it.

Everything is still treated as MultiMarkdown, it's just divided amongst
multiple files.

F-

6. Kolen closed this discussion on 02 Mar, 2016 02:51 AM.

Comments are currently closed for this discussion. You can start a new one.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^` on Mac

## Recent Discussions

 02 Apr, 2019 07:28 PM brew upgrade multimardown fails 04 Mar, 2019 11:16 AM Indexes and Tags 21 Feb, 2019 03:18 PM Support of ESC character 09 Feb, 2019 06:04 PM Superscript at beginning of line produces mixed results when previewed 08 Dec, 2018 08:58 PM TeX export broke from MMD3 to MMD4?