2

Background

Looking to embed images that are grid-aligned. More specifically, I'd like to render linearized absorption and emission spectral lines that do not cause the prose to typeset off-grid. (See also: RGB values of visible spectrum and Fraunhofer lines.)

mtx-context     | current version: 2019.06.11 19:20

Problem

In the following screen shot, two SVG files are imported into the document, but their heights (in combination with the top and bottom whitespace) throw the text off the grid:

First Exoplanets

Currently, the spectra are imported from SVG files. They don't need to be any particular height; preferably they'd be a height that allows ConTeXt to set the text that follows onto the grid. In effect, the three columns of text would have the same baseline.

As an aside, the subheadings (Relevance and Knowledge) also throw the text off of the grid layout.

Code

A minimum working example for both problems (subheadings and vector graphics) is difficult to recreate. Here are relevant parts.

Page & Columns

\definepapersize[BookPaperSize][
  width=24in,
  height=12in,
]

\setuppapersize[BookPaperSize]

\usemodule[newcolumnsets]

\definecolumnset[BookColumns][n=4,distance=.25in]
\setupcolumnset[BookColumns:1][width=11.75in]
\setupcolumnset[BookColumns:2][width=3.46in]
\setupcolumnset[BookColumns:3][width=3.46in]
\setupcolumnset[BookColumns:4][width=3.46in]

Grid Page Layout

\definemeasure[BookTextLayoutHeight][\dimexpr .5\paperheight - 1in\relax]

% halfline - Allow the chapter title and columnar text to top-align
\definelayout[BookTextLayout][
  topspace=.5in,
  backspace=.5in,
  width=\paperwidth,
  height=\measure{BookTextLayoutHeight},
  header=\zeropoint,
  footer=\zeropoint,
  setups=BookPenalties,
  grid=halfline,
]

\setuplayout[BookTextLayout]

\startsetups[BookPenalties]
  \setdefaultpenalties
  \setpenalties\widowpenalties{1}{10000}
  \setpenalties\clubpenalties {1}{10000}
\stopsetups

External Figures

\setupcaptions[location=none]

\setupexternalfigures[
  order={jpg,png,svg,pdf},
  location={local,default,global},
]

\def\inlinespectralexternalfigure[#1]{%
  \blank[small]
  \externalfigure[#1][width=\textwidth]
}

Fonts

\starttypescript [serif] [impactbody]
  \definefontsynonym [Serif]       [name:aleoregular] [features=default]
\stoptypescript

\starttypescript [sans] [impactheader]
  \definefontsynonym [SansCaps]   [name:gaugenormal][features={default,smallcaps}]
  \definefontsynonym [SansCapsBold][name:gaugebold][features={default,smallcaps}]
\stoptypescript

\definetypeface[impact] [rm] [serif] [impactbody]   [default]
\definetypeface[impact] [ss] [sans]  [impactheader] [default]

\usetypescript[impact]
\setupbodyfont[impact]

\def\FontSizeChapter{5}
\def\FontSizeSection{2.5}
\def\FontSizeSubsection{1.25}

\definefont[FontChapter][SansCapsBold sa \FontSizeChapter]
\definefont[FontSection][SansCaps sa \FontSizeSection]
\definefont[FontSubsection][SansCapsBold sa \FontSizeSubsection]

Headings & Initial Character

\setuphead[subsubsection][
  style=\FontSubsection,
  number=no,
  before={\blank},
  after={\blank[small]},
  margin=\zeropoint,
  beforecommand={\startlinecorrection},
  aftercommand={\stoplinecorrection},
]

\setupinitial[
  state=start,
  color=BookBaseColour,
  distance=.25em,
  font=SansCapsBold sa 4.25,
  n=3,
]

Illustrations

The vector graphics include:

Question

How would you set up the fonts and external figures to always grid-align?

Ideas

A few ideas that didn't work.

Line Correction

Using the linecorrection commands had no effect:

\def\inlinespectralexternalfigure[#1]{%
  \startlinecorrection
  \externalfigure[#1][width=\textwidth]
  \stoplinecorrection
}

Image Padding

Padding the SVG with whitespace was time-consuming, error-prone, and did not provide sufficiently fine-grained control to perfect the grid alignment.

Blank Commands

Inserting \blank with different amounts (small, depth) provide a bit more control, but still would not align perfectly.

| improve this question | | | | |
  • 2
    Too bad, that you don't have a MWE to play with. But have you tried out the grid snapping techniques described in It's in the details? – DG' Oct 21 '19 at 12:16
3

From the Grid trickery section of the manual:

\definefloat[inlinefigure][inlinefigures][figure]
\setupcaption[inlinefigure][inbetween=]
\setupfloat[inlinefigure][default={here,none}]

\def\inlinespectralexternalfigure[#1]{%
  \placeinlinefigure{}{%
    \externalfigure[#1][width=\textwidth,lines=1,grid=yes]
  }
}

Produces the following inline images with grid-aligned text:

Grid-aligned text

| improve this answer | | | | |

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.