From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Table of contents for just one section? Date: Sun, 26 Oct 2014 16:01:10 +0100 Message-ID: <87egtuq3ih.fsf@gmx.us> References: <87wq7uzwmm.fsf@nicolasgoaziou.fr> <871tpvmekr.fsf@nicolasgoaziou.fr> <87mw8joylh.fsf@gmx.us> <8761f7dlxd.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiPJy-0006eA-96 for emacs-orgmode@gnu.org; Sun, 26 Oct 2014 11:01:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XiPJt-0000co-9j for emacs-orgmode@gnu.org; Sun, 26 Oct 2014 11:01:30 -0400 Received: from plane.gmane.org ([80.91.229.3]:40456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiPJt-0000ch-0M for emacs-orgmode@gnu.org; Sun, 26 Oct 2014 11:01:25 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XiPJr-0007Kt-QT for emacs-orgmode@gnu.org; Sun, 26 Oct 2014 16:01:23 +0100 Received: from 217.130.110.20 ([217.130.110.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Oct 2014 16:01:23 +0100 Received: from rasmus by 217.130.110.20 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Oct 2014 16:01:23 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, Nicolas Goaziou writes: > Rasmus writes: > >> I think we can do it with titletoc. I have used other functionality >> of titletoc, and it 'doesn't sucks'ᵀᴹ. Below is an example. The >> output is more inline with normal tocs, but you can also style it >> [I've used this for making paragraph-TOCs in the past]. >> >> So ox-latex needs to insert at least the following to initialize a >> local TOC >> >> \startcontents[ID-level] % need not be unique and might not be neceasary >> \printcontents[ID-level]{}{(1+ level)}{TOC OPTIONS} >> >> And, importantly — and mildely annoyingly — \startcontents[ID] *after* >> the next heading of the same level. > > I don't quite get this part. Does that string need to be inserted only > after the second sibling (i.e., not after the third, too)? What happens > if there is no other sibling? Ah, it's much easier to use \stopcontents[level-i] to end contents collection. Revising the example: \documentclass{book} \usepackage{titletoc} \begin{document} \part{p1} \startcontents[level-0] \printcontents[level-0]{}{0}{\setcounter{tocdepth}{2}} \chapter{c1} \startcontents[level-1] \printcontents[level-1]{}{1}{\setcounter{tocdepth}{1}} \section{s1} \subsection{s2} \stopcontents[level-1] \chapter{c2} \section{s3} \stopcontents[level-0] \part{p2}\chapter{c3} \end{document} Note that the contents is determined by the .pcf file. Maybe that's easier to to understand than my babeling. Also, "pcf" should be added to `org-latex-logfiles-extensions'. >> There are some preamble options, but since we are doing it >> programically, it might be safer to insert it into the body. > > The patch will not insert "\usepackage{titletoc}" for the user, however, > à la `org-latex-listings'. Great. > What do you call the "brute force"? I meant to insert \startcontents[ID-level] after each, say, chapter unconditionally rather than inserterting as few \startcontents[ID-level] as possible. But ignore that: \stopcontents[ID-level] it's much cleaner. >> Let me know what you think and whether you will do it. > > I can try to implement it. > > I also note that these tocs do not have any title. Would it make sense > to remove title from local tocs in other back-ends too? No idea. Both makes sense, but maybe including the TOC-title is too verbose? In any case, I think it's easy to add a title if you. Based on article.cls and book.cls, I think we can generalize the toc-title to "heading one level down in level and unnumbered with title \contentsname". The TOC title for chapter is thus \section*{\contentsname}. For \part it's \chapter*{\contentsname}. I guess you can use the cdr in level part of `org-latex-classes', though it would be incompatible with e.g. \addsec{·} of KOMA-Script. —Rasmus Article.cls: \newcommand\tableofcontents{% \section*{\contentsname \@mkboth{% \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% \@starttoc{toc}% } Book.cls: \newcommand\tableofcontents{% \if@twocolumn \@restonecoltrue\onecolumn \else \@restonecolfalse \fi \chapter*{\contentsname \@mkboth{% \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% \@starttoc{toc}% \if@restonecol\twocolumn\fi } —Rasmus -- And I faced endless streams of vendor-approved Ikea furniture. . .