1

I want to create a title like the following:

_________________________________________________________________________________
|                             |                                    | Sufix      |
| Prefix unwrapped (CAPS)     | Unwrapped title (Small Caps)       | wraped     |
|                             |                                    | as needed  |
=================================================================================
        Ba ba                                  Ba ba
•     Sub text 1     •   Sub text 2   •      Sub text 3       •    Sub text 4   •
          Ba                                Black Sheep

It needs to be:

  • stretched full with of the page
  • underlined with colour (=)
  • there are no bothers on top, left, right or middle (|, _)
  • Subtext which is separated by a separator character (•) which is centre or top-aligned and adjusted for optimal fit.

So far what I have done is (1st part of the title/header):

\define[3]\TITLE{\midaligned{\framed[frame=off,align=middle,bottomframe=on,framecolor=blue]
                                {\inframed[frame=off]{{\tfa\WORD#1}: {\tfb\sc#2}}\inframed[frame=off]{{\tfa, #3}}}}}

But this does not produce the desired results.

How do I do it?

4
  • 1
    Can you please add a complete minimal working example? In particular, do you plan to use this as a standalone macro or as part of Context's heading mechanism (chapter, section, etc)?
    – Aditya
    Sep 8 '20 at 12:54
  • This is for one-off use as a title for CV. Sep 8 '20 at 16:43
  • Have you considered using tables?
    – Aditya
    Sep 8 '20 at 18:30
  • I am pretty new to ConTeXt. I started using it only today. I am not fully aware of all the options. No, I have not tried tables. Sep 8 '20 at 19:38
1

I don't completely understand the specs, so let me try to answer this iteratively.

  • I am assuming that the width of Prefix + Title < \textwdith. If not, then one of these two must also wrap.
  • It is not clear how Prefix and Title should be aligned vertically. I chose middle aligned (which is called lohi in ConTeXt)

Conceptually, the simplest method is to use TABLEs. So, the basic macro is:

\define[3]\TITLE
  {\startTABLE[setups=table:title]
      \NC #1 \NC #2 \NC #3 \NC \NR
    \stopTABLE}

Now, all we need to do is define the setups table:title to get the right formatting, which can be done as follows:

\startsetups table:title
  \setupTABLE[each][each][frame=off,bottomframe=on,rulethickness=2bp]
  \setupTABLE[column][1][style=WORD, align=lohi]
  \setupTABLE[column][2][style=\sc,  align=lohi]
  \setupTABLE[column][3][align={hyphenated,tolerant}]
\stopsetups

That's it!

Here is the complete code with the output:

\startsetups table:title
  \setupTABLE[each][each][frame=off,bottomframe=on,rulethickness=2bp]
  \setupTABLE[column][1][style=WORD, align=lohi]
  \setupTABLE[column][2][style=\sc,  align=lohi]
  \setupTABLE[column][3][align={hyphenated,tolerant}]
\stopsetups

\define[3]\TITLE
  {\startTABLE[setups=table:title]
      \NC #1 \NC #2 \NC #3 \NC \NR
    \stopTABLE}

\showframe % To visualize the page frame
\starttext

\TITLE{prefix}{Unwrapped title}{\dorecurse{5}{A very long text\space}}

\stoptext

which gives

enter image description here

The top and side frames are due to \showframe just to show that the table is extended to the edge of the page boundary.

2
  • There are two options to get smallcaps: style=\sc or style=smallcaps. The first internally does \setfontfeature{smallcaps} whereas the second does \doaddfeature{f:smallcaps}. No idea what is the difference (if any). Sep 9 '20 at 7:01
  • In my experience, style=\sc works with some fonts while style=smallcaps does not and vice-versa. With LM, style=smallcaps does not give the small caps effect.
    – Aditya
    Sep 9 '20 at 14:03

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.