sile icon indicating copy to clipboard operation
sile copied to clipboard

Add hfill-command parameter to TOC

Open raphCode opened this issue 2 years ago • 2 comments

This PR adds the parameter tableofcontents.hfill-command to control the way the space between the TOC entry and the page number is filled. By default this is dotfill which is the original behavior. But now it is trivially to change the setting inside e.g. tableofcontents:level1item to create different fill styles for the TOC levels:

image

raphCode avatar Dec 08 '22 21:12 raphCode

I noticed the following messages from @Omikhleia in my email inbox but can't find them here. I will answer for completeness:

Why a setting and not a tableofcontent parameter?

I am not sure what you mean?

And I don't get how it is expected to work if some toc levels should have dots but not all.

The idea was since tableofcontents:level1item is called with the actual TOC entry as the content, one can redefine the command and change the setting before processing the content:

self:registerCommand("tableofcontents:level1item", function (_, content)
  SILE.settings:temporarily(function()
    SILE.settings:set("tableofcontents.hfill-command", "hfill")
    SILE.call("font", { size = 14, weight = 800 }, content)
  end)
end)

raphCode avatar Dec 12 '22 23:12 raphCode

I noticed the following messages from @Omikhleia in my email inbox but can't find them here. I will answer for completeness:

Sorry about that. Too early posts, and I deleted them quite immediately after posting - It sounded all wrong to me to comment on a package I do not really use ^^. For completeness too: I do think that the whole "hook" paradigm to be very TeX-like, but quite wrong with respect to styling - my rationale is explained in the document I linked above in a further message - and that adding an additional layer of settings and complexity to them is inherently flawed, especially linking to a random command by name, but I shouldn't have commented anyhow regarding that tableofcontents package, since I use replacement(s) of thereof in my serious projects and don't really care what it does. In addition, it only would help, in what seems to me a very contrived "ad-hoc" way, addressing one specific aspects of ToC (the presence or absence of dot leaders), while many other aspects remain unaddressed (e.g. absence of page numbering for some levels, typically "parts" - but I don't use the "book" class either, so heh... ;) ).

Omikhleia avatar Dec 12 '22 23:12 Omikhleia