3

I'd like to replicate this heading style in ConTeXt:

enter image description here

The closest I've come is surrounding a centered text with \thinrules but those are at the baseline of the text instead of horizontally centered around the text:

\centeraligned{\thinrule SKILLS \thinrule}

Does someone have a solution? I'm sure it's possible with MetaFun but I haven't quite understood enough of that yet.

6

You can create raised rules with the \blackrule command. The correct width for the rules can be calculated when you measure the width of the section text with the \dowithnextbox command.

\define\SectionTextCommand
  {\dowithnextbox
     {\beginhbox
        \blackrule[width=\dimexpr(\hsize-\nextboxwd-2\emwidth)/2\relax,height=0.8ex,depth=-0.6ex,color=middlecyan]%
        \quad
        \copy\nextbox
        \quad
        \blackrule[width=\dimexpr(\hsize-\nextboxwd-2\emwidth)/2\relax,height=0.8ex,depth=-0.6ex,color=middlecyan]%
      \endhbox}
     \hbox}

\setuphead
  [subject]
  [textstyle={\setcharactercasing[WORD]\ssa},
   textcommand=\SectionTextCommand]

\starttext

\subject{Skills}

\stoptext

Another method is to use the filler mechanism to place rules at the left and right of the text which take the available space without the need to calculate it.

\definefiller
  [SectionRule]
  [alternative=rule,
   color=middlecyan,
   height=0.8ex,
   depth=-0.6ex]

\definefiller
  [SectionLeftRule]
  [SectionRule]
  [left=\zerowidthnobreakspace,
   right=\quad]

\definefiller
  [SectionRightRule]
  [SectionRule]
  [left=\quad,
   right=\zerowidthnobreakspace]

\setuphead
  [subject]
  [%align=middle,
   textstyle={\setcharactercasing[WORD]\ssa},
   textcommand=\groupedcommand{\filler[SectionLeftRule]}{\filler[SectionRightRule]}]

\starttext

\subject{Skills}

\stoptext
  • Wow, there's so much in this that I've never seen before, thank you! :-) – DP. Jun 26 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.