2

I'm learning how to use Context, and I'm having trouble creating a sub-section heading without a blank line underneath it. I'm using a baseline grid and want to continue to do so.

Is there a way to eliminate the blank line between "Sub-Section 1" and its paragraph? I accomplished the look I want in "Sub-Section 2", but it doesn't use a section heading and cannot be referenced.

enter image description here

% macros=mkvi
\usemodule[ipsum]

\setuppapersize[A5]
\setupbodyfont[10pt]

\definefont [Heading] [Serif at 20pt]
\definefont [ParagraphHeading] [SerifItalic at 13pt]

\setuphead [section] [
  style=\Heading,
  number=no,
  align=middle,
  before=,
  after=
]

\setuphead [subsection] [
  style=\ParagraphHeading,
  number=no,
  align=flushleft,
  before=,
  after=
]

\setupinterlinespace[line=1.5em]
\setuplayout [grid=yes]
\showgrid

\starttext
  \section{Section}
  \ipsum[alternative=lines,n=2]

  \subsection{Sub-Section 1}
  \ipsum[alternative=lines,n=2]

  \blank[1.5em]
  {\it \switchtobodyfont[13pt]{Sub-Section 2}}\\
  \ipsum[alternative=lines,n=2]
\stoptext

1 Answer 1

2

Grid snapping can get quite tricky.

The issue here is that you're using a larger font size in the headings, so the "depth" of the headings would overlap with the "height" of the following line. You can use grid=high to force the depths to round down instead of rounding up:

% macros=mkvi
\usemodule[ipsum]

\setuppapersize[A5]
\setupbodyfont[10pt]

% Added: *default
\definefont [Heading] [Serif*default at 20pt]
\definefont [ParagraphHeading] [SerifItalic*default at 13pt]

\setuphead [section] [
  style=\Heading,
  number=no,
  align=middle,
  before=,
  after=,
  grid=high,
]

\setuphead [subsection] [
  style=\ParagraphHeading,
  number=no,
  align=flushleft,
  before=,
  after=,
  grid=high,
]

\setupinterlinespace[line=1.5em]
\setuplayout [grid=yes]
\showgrid

\showmakeup[line] % Visualize the line heights/depths

\starttext
  \section{Section}
  \ipsum[alternative=lines,n=2]

  \subsection{Sub-Section 1}
  \ipsum[alternative=lines,n=2]

  \blank[1.5em]
  {\it \switchtobodyfont[13pt]{Sub-Section 2}}\\
  \ipsum[alternative=lines,n=2]
\stoptext

The "It's in the Details" manual has some more information about grid snapping, although it's a pretty technical read.

Also, you should almost always add *default when using \define(d)font to make sure that you get all of the default font features.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .