From ef409e965c28e053535a8ad32e71678aaa630763 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sat, 19 Feb 2022 19:57:29 +0100 Subject: [PATCH] org latex export change unnumbered section to be in toc and add section toc --- lisp/my/my-org-article.el | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/lisp/my/my-org-article.el b/lisp/my/my-org-article.el index 94861542..d3a4ec5e 100644 --- a/lisp/my/my-org-article.el +++ b/lisp/my/my-org-article.el @@ -408,9 +408,9 @@ Replaces <<...>> with values defined in (add-to-list 'org-latex-classes '("koma-article" "\\documentclass{scrartcl}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\cleardoublepage\\section{%s}\\thispagestyle{plain}" . "\\def\\my_org_article_section{%s}\\cleardoublepage\\section*{\\my_org_article_section}\\phantomsection\\addcontentsline{toc}{section}{\\my_org_article_section}\\thispagestyle{plain}") + ("\\subsection{%s}" . "\\def\\my_org_article_subsection{%s}\\subsection*{\\my_org_article_subsection}\\phantomsection\\addcontentsline{toc}{subsection}{\\my_org_article_subsection}") + ("\\subsubsection{%s}" . "\\def\\my_org_article_subsubsection{%s}\\subsubsection*{\\my_org_article_subsubsection}\\phantomsection\\addcontentsline{toc}{subsubsection}{\\my_org_article_subsubsection}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) @@ -530,6 +530,29 @@ Replaces <<...>> with values defined in % first: pnumwidth, second: margin, default: 1.55em and 2.55em \\cftlocalchange{toc}{2em}{2.55em} +% section toc +% minitoc does not work with koma script therefore: %TODO clean old minitoc (and \\sectoc commmand) stuff, there is also a \\chaptertoc version online +\\makeatletter +\\newif\\ifusesectiontoc% Switch to tell \\addtocentrydefault to not only make entries to the toc-file but also to the current section-toc-file +\\newcommand*{\\sectiontoc}{% new command to generate and show a section toc + \\usesectiontoctrue% switch on section-toc-entries + \\edef\\ext@subtoc{toc\\thesection}% extension of the section-toc-file, e.g., toc1.1 + \\expandafter\\DeclareNewTOC\\expandafter{\\ext@subtoc}% declare a new toc file + \\begin{minipage}{.9\\linewidth} + \\value{tocdepth}=\\subsectiontocdepth% we want entries down to subsection + \\expandafter\\listoftoc\\expandafter*\\expandafter{\\ext@subtoc}% show the toc without any heading + \\end{minipage}\\par + \\bigskipa\\noindent% add some vertical space after the toc and do not indent the following text +} +\\usepackage{xpatch} +\\xapptocmd\\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator + \\ifusesectiontoc% if section toc entries should be generated + \\expandafter\\tocbasic@addxcontentsline\\expandafter{\\ext@subtoc}{#1}{#2}{#3}% do it + \\fi +}{}{} +\\xpretocmd\\section{\\usesectiontocfalse}{}{}% automatically switch of section toc entries at start of every \\section +\\makeatother + %\\usepackage{bigfoot} % footnote