I want to create a table of contents for sets only including the book titles. Can you give me a hint where to start? Is it possible to extend the autotoc.xsl? Or is it better to create an own template?
Currently I have a toc at the beginning of the set showing each entry of each book. But here I just need the books listed. The detailed toc should be shown in the book itself.
Regards,
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree with Stefan, the autotoc.xsl file is a good start. To help you find your way, here are some additional tips.
I want to create a table of contents for sets only including the book titles.
Just to understand you correct, you want to change only the set TOC, but not the usual book TOC, right?
In that case, I would try to customize the set.toc template. Replace the call for make.toc with your own code, for example:
<xsl:templatename="set.toc"><xsl:paramname="toc-context"select="."/><xsl:paramname="toc.title.p"select="true()"/><!-- Change the variable to your needs: --><xsl:variablesname="nodes"select="book|article"/><xsl:apply-templatesselect="$nodes"mode="set.toc"/></xsl:template>
Inside the set.toc mode you use something similar to this:
If that doesn't work, here are some further explanations:
The templates in the autotoc.xsl file operates in these two modes:
toc-abstract is used to create a summary for set and part elements. It uses the abstract elements to give you an additional hint about your books or parts. (This mode is created by us).
toc is the "normal" mode which is also used from the upstream DocBook XSL stylesheets. This mode collects all the titles from the document.
Additionally, we've customized the folloing templates:
make.toc creates the complete TOC. For elements like set or part, it creates the summary used by the toc-abstract mode. For other elements, it uses the normal toc mode.
toc.line creates the line pointing to the respective position in the document. Usually, this template creates the HTML a element. The difference between the upstream and this element is, that it distinguish between the label (=number) and its title. This is needed to present the label with a different style than its title.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Uh, that is a good question. I think you are using a modified version of our SUSE stylesheets. I must admit, I think we (that is, mostly I) broke some parts of autotoc a bit. In particular, there is a ToC depth parameter, something akin to $toc.max.depth that might be helpful but is probably a bit broken in the HTML version (I don't think we ever changed much about the set ToC in the PDF version -- that use case was never quite as important to us).
Nevertheless, I guess it is a good idea to at least start with some code from autotoc, even if you copypasta it around to somewhere else. That way, at least, most of the hard stuff is already done and you can focus on bells/whistles.
Last edit: Stefan Knorr 2017-11-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to create a table of contents for sets only including the book titles. Can you give me a hint where to start? Is it possible to extend the autotoc.xsl? Or is it better to create an own template?
Currently I have a toc at the beginning of the set showing each entry of each book. But here I just need the books listed. The detailed toc should be shown in the book itself.
Regards,
Martin
Hi Martin,
I agree with Stefan, the
autotoc.xsl
file is a good start. To help you find your way, here are some additional tips.Just to understand you correct, you want to change only the
set
TOC, but not the usualbook
TOC, right?In that case, I would try to customize the
set.toc
template. Replace the call formake.toc
with your own code, for example:Inside the
set.toc
mode you use something similar to this:I don't know if this does work. Try it and you will see. ;-)
Hope this help.
Good luck and if you have questions, just ask.
If that doesn't work, here are some further explanations:
The templates in the
autotoc.xsl
file operates in these two modes:toc-abstract
is used to create a summary forset
andpart
elements. It uses theabstract
elements to give you an additional hint about your books or parts. (This mode is created by us).toc
is the "normal" mode which is also used from the upstream DocBook XSL stylesheets. This mode collects all the titles from the document.Additionally, we've customized the folloing templates:
make.toc
creates the complete TOC. For elements likeset
orpart
, it creates the summary used by thetoc-abstract
mode. For other elements, it uses the normaltoc
mode.toc.line
creates the line pointing to the respective position in the document. Usually, this template creates the HTMLa
element. The difference between the upstream and this element is, that it distinguish between the label (=number) and its title. This is needed to present the label with a different style than its title.I will try your suggestion. I think that will take a while.
Regards
Martin
Uh, that is a good question. I think you are using a modified version of our SUSE stylesheets. I must admit, I think we (that is, mostly I) broke some parts of autotoc a bit. In particular, there is a ToC depth parameter, something akin to
$toc.max.depth
that might be helpful but is probably a bit broken in the HTML version (I don't think we ever changed much about the set ToC in the PDF version -- that use case was never quite as important to us).Nevertheless, I guess it is a good idea to at least start with some code from autotoc, even if you copypasta it around to somewhere else. That way, at least, most of the hard stuff is already done and you can focus on bells/whistles.
Last edit: Stefan Knorr 2017-11-27