TransWikia.com

ConTeXt: is it possible not to apply setuplayout to part and chapter headers?

TeX - LaTeX Asked by pid on November 1, 2021

I need to have space for margin notes on my document, which I have done with the following setuplayout (from this link):

setuplayout[topspace=10mm,
             width=middle,
             height=270mm,
             header=10mm,
             headerdistance=0pt,
             footerdistance=0pt,
             footer=0pt,
             bottom=10mm,
             bottomdistance=0pt,
             cutspace=60mm,
             rightmargin=50mm,
             rightmargindistance=5mm]

However, this layout obviously affect part and chapter head placements.

So, is it possible not to apply setuplayout to part and chapter headers?

One Answer

So, is it possible not to apply setuplayout to part and chapter headers?

No, this is not possible. The settings in setuplayout determine the dimensions of the paper that the content will be printed on and since parts and chapters are going to be printed on the same paper as the rest of the document, it is illogical to have setuplayout somehow “ignore” them.

What you want to do is still possible* by setting the width key in setuphead for the specified entries.

Using the default head alternative

The default headrendering will then adjust the size of the textblock to the specified width only for the heading.

* This is usually a sign that you were asking the wrong question.

showgrid
showframe

setuplayout[topspace=10mm,
             width=middle,
             height=270mm,
             header=10mm,
             headerdistance=0pt,
             footerdistance=0pt,
             footer=0pt,
             bottom=10mm,
             bottomdistance=0pt,
             cutspace=60mm,
             rightmargin=50mm,
             rightmargindistance=5mm]

setuphead
    [chapter]
    [width=dimexprmakeupwidth+rightmargindistance+rightmarginwidthrelax]

starttext

startchapter[title={A very long chapter name just for the example}]

samplefile{knuth}

stopchapter

stoptext

enter image description here

Using a custom head alternative

If you are using a different alternative than the default normal, then you will have to make it aware of the adapted width manually. In the comments you mentioned that you are using a custom alternative based on this answer of mine. This is simple to adapt to the new requirements by setting hsize to headwidth inside the vbox that contains the heading. The dimension headwidth is set to the width parameter that you supplied to setuphead within the headrendering code.

showgrid
showframe

setuplayout[topspace=10mm,
             width=middle,
             height=270mm,
             header=10mm,
             headerdistance=0pt,
             footerdistance=0pt,
             footer=0pt,
             bottom=10mm,
             bottomdistance=0pt,
             cutspace=60mm,
             rightmargin=50mm,
             rightmargindistance=5mm]

defineheadalternative
  [centered]
  [alternative=vertical,
   renderingsetup=headrenderings:centered]

startsetups[headrenderings:centered]
    vbox {
        ifzeroptheadwidthelse
            hsizeheadwidth
        fi 
        headsetupspacing
        veryraggedcenter
        let\endgraf
        letcrlfendgraf
        ifconditionalheadshownumber
            strut
            headnumbercontent
            %par % <-- commented out
        else
            fakeheadnumbercontent
        fi
        begstrut
        headtextcontent
        endstrut
    }
stopsetups

setuplabeltext[en][chapter=Chapter ]

setuphead
    [chapter]
    [width=dimexprmakeupwidth+rightmargindistance+rightmarginwidthrelax,
     commandbefore={:,},
     alternative=centered]

starttext

startchapter[title={A very long chapter name just for the example}]

samplefile{knuth}

stopchapter

stoptext

enter image description here

Answered by Henri Menke on November 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP