# Table of contents in export

#### sahilagnihotri

05 Oct, 2013 03:11 PM

Hey ,
i am having difficulty finding how to have table of contents in the HTML exported , i see it in preview in app but is there a way or a tag to have table of contents as apart of html (other than editing html) , pdf outputs .

Thanks and Regards,
Sahil Agnihotri

1. Support Staff Posted by Brett on 05 Oct, 2013 03:17 PM

Try <!--TOC--> in the Markdown, it should do what you want. You can also use a max# parameter to control the depth of the TOC: http://marked2app.com/help/Special_Syntax.html

2. Posted by Rocketman on 06 Mar, 2014 09:29 AM

I'm having the same problem. It prints the Table of contents fine. But when I export to HTML it does not work. I've added <!--TOC--> but it does not help.

3. Support Staff Posted by Brett on 06 Mar, 2014 01:50 PM

TOC doesn't work in HTML export.

4. Posted by Rocketman on 06 Mar, 2014 02:53 PM

Thanks, that's what I suspected. Would have been nice though.

5. Support Staff Posted by Brett on 06 Mar, 2014 03:01 PM

The Table of Contents is generated by JavaScript, so if you needed to,
you could actually embed the javascript in your exported documents. Let
me know if that's something that would be workable for your needs and
I'll look into making it possible.

-Brett

6. Posted by Rocketman on 06 Mar, 2014 06:12 PM

Thanks, that works fine. Powerful.

7. Posted by Jonathan on 21 Aug, 2015 09:24 PM

Would it be possible to add a "embed TOC javascript" check to the HTML save box if you've either said to print TOC in prefs or added <!--TOC-->?

Alternatively, add a checkbox to save to embed generated TOC HTML into the HTML export?

8. Support Staff Posted by Brett on 21 Aug, 2015 09:38 PM

Next update will embed the TOC as actual HTML under those circumstances.

9. Posted by Jonathan Bennet... on 21 Aug, 2015 11:24 PM

Thanks, brett!

(Markdown + Marked2 n00b, and really appreciating the app)

10. Posted by btoone on 23 Aug, 2015 03:59 PM

Hi just a follow-up question to this. After reading http://marked2app.com/help/Special_Syntax.html#tableofcontents I'm wondering if there is a way to make the table of contents show when exporting to HTML but not in preview. In other words, I'd like to use the cmd+T window while previewing but have links at the top when exporting.

When I have the "Print table of contents" box checked it behaves this way for printing, just not exporting to HTML.

11. Support Staff Posted by Brett on 23 Aug, 2015 04:16 PM

Not for HTML export. "Print TOC" only affects print and PDF export. HTML
export only gets what's in the preview right now.

It's possible to apply some CSS using the "Additional CSS" in Style
preferences to hide elements in the preview that aren't hidden in export
because Marked applies some special classes during preview. However,
these are dependent on the current theme, so the rule would have to be
repeated if you use multiple themes. Here's an example:

.mkstyle--swiss #mkreplaced-toc {
display: none!important;
}

The 'mkstyle--swiss' class is not exported, so the rule would have no
effect in HTML outside of Marked. It's not an ideal solution, but it's
assumed that if you want a manually-inserted TOC, you want it in both
places, and there's currently no option to automatically generate one
during export because it's generating the exported HTML prior to display
in the preview window, and the TOC is generated with JavaScript within
the preview.

-Brett

12. Posted by btoone on 23 Aug, 2015 04:54 PM

Great, thanks for the clarification and work-around.

13. Posted by Hans on 04 Jan, 2016 03:43 PM

With <!--TOC--> I can create a Table of Contents, which is beautifully exported to PDF. However, when I click on an item of this TOC in the PDF, there is no jump to the corresponding chapter. Is it possible to have this working?

14. Support Staff Posted by Brett on 04 Jan, 2016 05:09 PM

@info: please see this discussion

## Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# 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

 21 Feb, 2020 11:32 PM Option to use MathJax 3? 20 Feb, 2020 03:12 PM Regular crashes 13 Feb, 2020 09:22 PM Markdown Formatting 11 Feb, 2020 11:53 AM Custom themes not working 10 Feb, 2020 06:48 PM KaTex Preview Update

## Recent Articles

 Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized Highlight sentences longer than a certain number of words How do I retrieve a lost license (direct version)