3

I'm using a custom typescript (after help in this question) which includes (among other things) two additional weights, medium and semibold, and their size modifiers (like \tfa, \tfb and so on). Because of custom weights, I've created custom macros for semibold italics, medium italics and so on (\sbi and \mdi, among others), as \em doesn't alternate regular/italics in custom weights.

I use then semibold in heads with size modifiers (globally configured), and those heads are independently styled in TOC (with regular weight), which works as expected. But when I use my custom macro \sbi in a particular head, it's typeset in body size, not in head size (say, like \sbic). And in TOC it gets semibold italics, not regular italics. Even worse, If I use semibold italics with size modifier in that particular head (say, \sbic), it gets that same size in TOC.

Question: is there any way of totally independently style heads in document and in TOC? Two possibilities would work:

  • in TOC, completely remove any particular style/weight of heads (acceptable)
  • correctly alternate between regular and italics, both in document and in TOC, according to surrounding weight (in my case, semibold in text and regular in TOC)

My typescript (excerpt):

\definebodyfont [default] [rm]
  [tf=Serif            sa 1,
   bf=SerifBold        sa 1,
   it=SerifItalic      sa 1,
   % ...
   mdf=SerifMedium        sa 1,
   mif=SerifMediumItalic  sa 1,
   msf=SerifMediumSlanted sa 1,
   % ...
   sbf=SerifSemibold        sa 1,
   sbi=SerifSemiboldItalic  sa 1,
   sbs=SerifSemiboldSlanted sa 1,
   % ...
   sbfb=SerifSemibold sa 1.440,
   sbfc=SerifSemibold sa 1.728,
   % ...
   sbib=SerifSemiboldItalic sa 1.440,
   sbic=SerifSemiboldItalic sa 1.728,
   % ...
   ]

And my document (excerpt):

\setupbodyfont[garamond-premier, 12pt] % my typescript

\setuphead[chapter]   [style={\sbfc}] % heads in document: semibold
\setuphead[section]   [style={\sbfb}]

\setupcombinedlist[content][list={chapter, section}]
\setuplist[chapter]   [style={\tf}] % heads in TOC: regular
\setuplist[section]   [style={\tf}]

\starttext
\completecontent

\chapter[title={A chapter with {\sbic italics}}]
A text

\section[title={A section with {\sbib italics}}]
Another text
\stoptext

Result (TOC and document, excerpt. Note incorrect weight and size in italics in TOC):

Screenshot

  • You're using way too many weights. Don't use more than two weights in your document, one regular and one bold. As you can see ConTeXt does not really support more than two weight, because it does not make sense to use more than two. – Henri Menke Jan 12 at 5:35
  • Related: ConTeXt: Font weights – Henri Menke Jan 12 at 5:42
  • I don't use more than two weights in each block of text: semibold is used only in heads, because bold seems to me excessively black in heads. I'm pretty new to ConTeXt, but it seems to me that one of its goals is to allow user to customize things as freely as possible in a consistent way (that consistence is what makes me prefer ConTeXt to LaTeX), so a consistent way of using more than two weights should be part of ConTeXt, don't you think? – José de Mattos Neto Jan 13 at 19:37
2

Instead of adding additional alternatives for your fonts you should create separate typefaces for the medium or heavy weights. To access the extra weights for the chapter titles and list entries you can switch to a different typeface with the \switchtobodyfont command.

\setupbodyfont
  [antykwapoltawskiego]

\setuphead
  [chapter]
  [page=no,
   style={\switchtobodyfont[antykwapoltawskiego-light]\bfb}]

\setuplist
  [chapter]
  [style={\switchtobodyfont[antykwapoltawskiego-light]\bf}]

\setuppapersize [A5]

\starttext

\completecontent

\chapter{Weisman}

\samplefile{weisman}

\chapter{Ward}

\samplefile{ward}

\stoptext

enter image description here

  • Thank you, this kind of works, but it needs two more things to completely work: in \setupbodyfont one needs to put both typefaces (so their alternatives are correctly recognized); after \starttext, one needs to use \switchtobodyfont to select which font will be used. Also, in your example you didn't use alternatives (italics) with custom weight (light), which is my specific problem. – José de Mattos Neto Jan 13 at 19:27
  • Although @HenriMenke 's solution also works, this is more suitable to me, because it makes \em correctly alternate italics even in custom weights, because, well, those weights are another typeface. – José de Mattos Neto Jan 13 at 19:28
3

In my last post, which you referenced in the question, I made a mistake.

Font alternatives can only have two letters, because ConTeXt will use anything after it as the size specifier, as the b in \tfb.

Furthermore, before assigning the font alternatives you actually have to define them. The code below rectifies all these problems. To not have the font switches show up in the TOC, you can assign an alternative text using list. I also recommend to use \start...\stop pairs of all commands.

\loadtypescriptfile[garamond-premier]

\definefontalternative[mf]
\definefontalternative[mi]
\definefontalternative[ms]
\definefontalternative[sf]
\definefontalternative[si]
\definefontalternative[ss]

\definebodyfont [default] [rm]
  [tf=Serif            sa 1,
   bf=SerifBold        sa 1,
   it=SerifItalic      sa 1,
   sl=SerifSlanted     sa 1,
   bi=SerifBoldItalic  sa 1,
   bs=SerifBoldSlanted sa 1,
   sc=SerifCaps        sa 1,
   %
   mf=SerifMedium        sa 1,
   mi=SerifMediumItalic  sa 1,
   ms=SerifMediumSlanted sa 1,
   %
   sf=SerifSemibold        sa 1,
   si=SerifSemiboldItalic  sa 1,
   ss=SerifSemiboldSlanted sa 1]
\stoptypescript

\setupbodyfont[garamond-premier]

\setuphead[chapter]   [style={\sfc}] % heads in document: semibold
\setuphead[section]   [style={\sfb}]

\setupcombinedlist[content][list={chapter, section}]
\setuplist[chapter]   [style={\tf}] % heads in TOC: regular
\setuplist[section]   [style={\tf}]

\starttext
\completecontent

\startchapter
  [title={A chapter with {\si italics}},
   list={A chapter with italics}]

  A text

  \startsection
    [title={A section with {\si italics}},
     list={A section with italics}]

    Another text

  \stopsection

\stopchapter

\stoptext

enter image description here

  • Thank you! This works, but as \em doesn't recognize custom alternatives, this is not the best solution for my case, as I need to use \em. Also, in the TOC of your example, the word "italics" is typeset as semibold, which is one of my problems (wrong weight and size in TOC item). – José de Mattos Neto Jan 13 at 19:31
  • @JosédeMattosNeto If you put font switches in the chapter title, they'll appear in the TOC. You'd have the same problem with traditional \bf. I'm a bit confused what your requirements are. I thought the number one priority was to have font switching commands like \si available. – Henri Menke Jan 13 at 22:16
  • my priority was to have heads with semibold weight, allowing words in italics whenever needed, and in TOC have those heads in regular weight, but respecting italics (with italics from regular weight). – José de Mattos Neto Jan 15 at 23:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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