Re: TOC placement in pdf
Bob Stayton <[email protected]> Thu, 23 Feb 2023 09:22:34 -0800
| Newsgroups | gmane.text.docbook.apps |
|---|---|
| Message-ID | <[email protected]> |
--------------91Reh0d1eTQmU3zbwnMYsJ63 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Actually, there's a param for that. If you insert an empty <toc/> element in your content, and set this param: process.empty.toc.element=1 and set generate.toc to blank (to turn off the default toc), then the stylesheet will generate a toc where that <toc/> element is located. Apparently this param came after the last edition of my book so it isn't covered there, but it is included in the fo parameter reference doc online. Unfortunately, the content model of article does not allow a toc element after normal content, even though the stylesheet doesn't care. So you either have to tolerate a validation error, or insert the empty toc element just before processing. Perhaps a cleaner customization would be to insert a processing instruction instead of an empty toc element so it validates, and write some XSL to process that PI using the XSL code borrowed and customized from the template that starts with <xsl:template match="chapter/toc | appendix/toc | preface/toc | article/toc"> from fo/toc.xsl. Basically you want to call the template named 'component.toc' but with the right context. I haven't tried this, but it should work. Bob On 2/22/2023 9:15 PM, rohith R wrote: > Hmmm, > I'll check. > I'd prefer to control it via xsl if that's possible as it provides max > flexibility. > Not sure if it's possible 🤔 > > On Tue, 21 Feb 2023, 6:17 pm Dave Pawson, <[email protected]> wrote: > > Can you use the <toc/> element to place it where you want? > > > HTH > > On Tue, 21 Feb 2023 at 06:28, Richard Hamilton > <[email protected]> wrote: > > > > Hello, > > > > The element I’ve used to put things before the toc is > <dedication>, which allows a lot more elements than you might > expect, including paragraphs and tables. > > > > It is an abuse of the tag, (I’ve used it only for a dedication > in our books), but in a pinch, it might do what you need. > > > > I’m sure others on this list may have some good (probably > better:) ideas, but I’m not sure you can do what you want to do > with any other element, unless you modify the stylesheets. > > > > I hope that helps. > > Dick Hamilton > > ------- > > XML Press > > XML for Technical Communicators > > http://xmlpress.net > > [email protected] > > > > > > > > > On Feb 20, 2023, at 23:04, rohith R <[email protected]> > wrote: > > > > > > Hi, > > > > > > > > > I'm using an article style docbook and convert it into pdf. > > > > > > The TOC is getting generated after the title page. I want it > before the section but after the front matter. How can I > accomplish this? > > > > > > My article structure (docbook5): > > > - title page > > > - other stuff (text and couple of tables) > > > - multiple sections <section> > > > > > > I want the TOC placed after "other stuff" and before sections. > > > > > > How can I accomplish it? > > > At the moment they get generated after title page when > generating pdf. > > > > > > Regards, > > > R > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [email protected] > > For additional commands, e-mail: > [email protected] > > > > > -- > Dave Pawson > XSLT XSL-FO FAQ. > Docbook FAQ. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: > [email protected] > --------------91Reh0d1eTQmU3zbwnMYsJ63 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p><font size="2"><font face="Helvetica, Arial, sans-serif">Actually, there's a param for that. If you insert an empty <toc/> element in your content, and set this param:</font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">process.empty.toc.element=1</font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">and set generate.toc to blank (to turn off the default toc), then the stylesheet will generate a toc where that <toc/> element is located. Apparently this param came after the last edition of my book so it isn't covered there, but it is included in the fo parameter reference doc online.<br> </font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">Unfortunately, the content model of article does not allow a toc element after normal content, even though the stylesheet doesn't care. So you either have to tolerate a validation error, or insert the empty toc element just before processing.</font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">Perhaps a cleaner customization would be to insert a processing instruction instead of an empty toc element so it validates, and write some XSL to process that PI using the XSL code borrowed and customized from the template that starts with <br> </font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif"><xsl:template match="chapter/toc | appendix/toc | preface/toc | article/toc"></font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">from fo/toc.xsl. Basically you want to call the template named 'component.toc' but with the right context. I haven't tried this, but it should work.<br> </font></font></p> <p><font size="2"><font face="Helvetica, Arial, sans-serif">Bob</font></font><br> </p> <div class="moz-cite-prefix">On 2/22/2023 9:15 PM, rohith R wrote:<br> </div> <blockquote type="cite" cite="mid:CAJnYUCQJa5LDfSBzREH9qta=0PEfvdYsiT1mgwH78opF-Q_C=w@mail.gmail.com"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <div dir="auto">Hmmm, <div dir="auto"> I'll check.</div> <div dir="auto">I'd prefer to control it via xsl if that's possible as it provides max flexibility.</div> <div dir="auto">Not sure if it's possible 🤔 </div> </div> <br> <div class="gmail_quote"> <div dir="ltr" class="gmail_attr">On Tue, 21 Feb 2023, 6:17 pm Dave Pawson, <<a href="mailto:[email protected]" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can you use the <toc/> element to place it where you want?<br> <br> <br> HTH<br> <br> On Tue, 21 Feb 2023 at 06:28, Richard Hamilton <<a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> ><br> > Hello,<br> ><br> > The element I’ve used to put things before the toc is <dedication>, which allows a lot more elements than you might expect, including paragraphs and tables.<br> ><br> > It is an abuse of the tag, (I’ve used it only for a dedication in our books), but in a pinch, it might do what you need.<br> ><br> > I’m sure others on this list may have some good (probably better:) ideas, but I’m not sure you can do what you want to do with any other element, unless you modify the stylesheets.<br> ><br> > I hope that helps.<br> > Dick Hamilton<br> > -------<br> > XML Press<br> > XML for Technical Communicators<br> > <a href="http://xmlpress.net" rel="noreferrer noreferrer" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">http://xmlpress.net</a><br> > <a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> ><br> ><br> ><br> > > On Feb 20, 2023, at 23:04, rohith R <<a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> > ><br> > > Hi,<br> > ><br> > ><br> > > I'm using an article style docbook and convert it into pdf.<br> > ><br> > > The TOC is getting generated after the title page. I want it before the section but after the front matter. How can I accomplish this?<br> > ><br> > > My article structure (docbook5):<br> > > - title page<br> > > - other stuff (text and couple of tables)<br> > > - multiple sections <section><br> > ><br> > > I want the TOC placed after "other stuff" and before sections.<br> > ><br> > > How can I accomplish it?<br> > > At the moment they get generated after title page when generating pdf.<br> > ><br> > > Regards,<br> > > R<br> ><br> ><br> > ---------------------------------------------------------------------<br> > To unsubscribe, e-mail: <a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> > For additional commands, e-mail: <a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> ><br> <br> <br> -- <br> Dave Pawson<br> XSLT XSL-FO FAQ.<br> Docbook FAQ.<br> <br> ---------------------------------------------------------------------<br> To unsubscribe, e-mail: <a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> For additional commands, e-mail: <a href="mailto:[email protected]" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> <br> </blockquote> </div> </blockquote> </body> </html> --------------91Reh0d1eTQmU3zbwnMYsJ63--