TOC in Current Page

Creates a table of contents from heading in the current page and inserts at the top of the page. Optionally it adds "Back to Top" links to the headings.

Download

Author(s) : Onetastic ★
Category : TOC
Last Updated : September 22, 2023
Requirements : OneNote 2010 or above
Watch this short video to learn more about this macro
Screenshot :

TOC in Current Page

Include headings up to
Changelog :

September 22, 2023 (50A1D8) - Onetastic ★
Fixed a second issue which would result in an empty line before the last item in the TOC

December 16, 2022 (9B42F1) - Onetastic ★
Fixed an issue where an empty line would appear before the last item in the TOC

December 13, 2022 (169982) - Onetastic ★
Added menu to quickly select the heading level. Fixed an issue where there would be extra space left after the TOC or TOC would be incorrectly generated when different levels are selected.

August 08, 2022 (EFAC69) - Onetastic ★
Fixed an issue where the macro will fail with an error on some pages with images

May 14, 2022 (9F1898) - Onetastic ★
Fixed a bug where page content would be removed if it consists of tables or other non-text content

January 17, 2022 (EE2A63) - Onetastic ★
Added option to have the TOC contain list numbers if the headings are part of a numbered list.

December 07, 2020 (10CBCC) - Onetastic ★
Added option to choose heading level for TOC

May 28, 2018 (CF836A) - Onetastic ★
Fixed an issue where the macro will fail with an error

April 24, 2018 (1B3508) - Onetastic ★
Fixed an issue where the "Back to Top" links wouldn't be updated if they already exist. Also the macro will now remember the "Back to Top" setting.

December 17, 2017 (EA5512) - Onetastic ★
Updated to refresh the TOC in the current page if it already exists.

September 04, 2016 (157AED) - Onetastic ★
Now finds all the headers in the page, even if they are in a table.

August 16, 2016 (C55DB0) - Onetastic ★
Re-added the option for "Back to Top" links, which was lost in the previous update.

July 30, 2016 (A20BF1) - Onetastic ★
TOC now uses indents based on heading level so that it can be collapsed

June 20, 2016 (E0E260) - Onetastic ★
Re-written with the new Macro Language to take advantage of cleaner syntax and performance improvements

These versions are no longer supported:

July 24, 2014 - Onetastic ★
Added the option for "Back to Top" links.

March 17, 2013 - Onetastic ★
Initial version

Comments

Name
Comment
Onetastic ★ - 2024-08-24
Tony63: Edit your custom styles and make sure the Underlying Style option is checked, and the corresponding built-in style is selected. That way the TOC macro will be able to identify those paragraphs. You might have to re-apply the heading styles after changing the custom style so that the paragraphs get the underlying styles.
Tony63 - 2024-08-23
I noticed that I  need to use the default Format styles to run the TOC for a page.  When I try to use a custom format, like Heading 1, that heading is not included.

I am wondering if I am missing something.

Thank you
zhongye - 2023-07-18
When updating the directory, the original directory was not overwritten repeatedly, resulting in two directories.
Show more comments (112 more)