Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

titletoc: \contentsmargin with font-dependent units causes misalisngment #75

Open
sim642 opened this issue Sep 8, 2024 · 0 comments
Open

Comments

@sim642
Copy link

sim642 commented Sep 8, 2024

The documentation for \contentsmargin does say

Although standard classes use font dependent units (mainly em), it is recommended using absolute ones (pc, pt, etc.) to ensure they entries are aligned correctly.

But that's a bit of an understatement because it really doesn't work at all when font size is changed for some \titlecontents, e.g. when trying to replicate standard \part look.

What's particularly confusing is that, when \contentsmargin isn't used, but the standard \@pnumwidth and \@tocrmarg are used to tune the same things, em-s are just fine, even with titletoc.
From what I understand, this is because titletoc uses those by default, but redefines them to always be in pt-s (by going through tempskipa) during initialization:

titlesec/titletoc.sty

Lines 581 to 584 in e5b48d9

\@tempskipa\@pnumwidth
\edef\@pnumwidth{\the\@tempskipa}
\advance\@tempskipa-\@tocrmarg
\edef\ttl@corr{-\the\@tempskipa}

It would be nice if font-dependent units still worked for \contentsmargin even when \titlecontents changes font size for a particular kind. It looks like currently \pnumwidth is used a few times, but there may be a font size command between, causing misalignment.

As a workaround, instead of changing font size in the <above-code> part of \titlecontents, duplicating it in <numbered-entry-format>, <numberless-entry-format> and <filler-page-format> (in the optional argument for \contentspage) avoids the problem. Although I didn't check if that maybe has some other unintended effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant