I’m trying to replicate a LaTeX template where the heading of each chapter has a black rectangle that stretches to the right margin, as shown in the picture below.
Please ignore the fact that the style of this heading does not perfectly match the one of the heading before. What concerns me in this post is just how to draw the rectangle at the side of the page. Here are the specifics of the solution I would like to find:
No hardcoded values, like in the #place call above where dx: 75pt or height: 9% are used. The rectangle should adapt dynamically to the content of the heading.
The height of the rectangle should perfectly match the height of the parent element. In the snippet above, the rectangle should have exactly the same height as the surrounding #block.
Hi @sjfhsjfh, thanks for your code! Yes, your snippet was actually useful. I made some modifications to suit it to a variant of the specification I gave earlier, and the result is as follows:
My only question at this point is, is there any mistake in the way the numbering style of the heading is fetched? When I pasted your snippet as-is into my code, the compiler was issuing an error saying it was receiving a none value instead of the numbering style (“1.” in my case).
I assumed that you have already set the numbering for heading in the former document like:
#set heading(numbering: "1.")
If you didn’t do this you will have context heading.numbering to be none. My purpose of doing this to keep consistency. However it seems that you would like to use a different pattern from the one in the document, then simply using .display("1") would be fine.
I just bumped into this a few minutes ago. I was using an outline in the document, and outlines set heading.numbering to none. You can test this easily to figure out if that is where it breaks: replace the line with