ment.createElement('div');
        tocContainer.id = 'quarto-margin-sidebar-toc';
        tocContainer.style.position = 'relative';
        tocContainer.style.padding = '10px';
        // tocContainer.style.border = '1px solid #ddd';
        sidebar.appendChild(tocContainer);
      }
    }
  }

  // Initialize TOC container and run the TOC generation
  createTOCContainer();
  updateActiveTabTOC();

  // Listen for tab changes to regenerate the TOC
  document.addEventListener('shown.bs.tab', function(event) 