En pocas palabras
Unas páginas de Alicia en el país de las maravillas con notas del editor en el margen. Cada nota va junto a las líneas que explica, marcada con una letra de color.
Lo que vas a componer
El comienzo del capítulo VII de Alice’s Adventures in Wonderland, la merienda de locos, en tres páginas de una edición anotada de 156 × 234 mm. El texto de Carroll va en una columna justificada de Unna, de unos 66 caracteres por línea. Un canal de 33 mm junto al corte exterior recoge las ocho glosas del editor, cada una al lado del párrafo que lleva su llamada, a la derecha en las páginas impares y a la izquierda en las pares. Las de palabras y chistes van en verde y las de historia en rojo, igual que las letras que las llaman. El capítulo se abre bajo una acuarela de la mesa del té vista desde arriba, con el número, el título en Rozha One y una entradilla en cursiva con capitular verde, y en el margen, junto a la entradilla, va la nota sobre esta edición.
Esta receta responde a
- ¿Cómo pongo notas al margen o glosas junto al párrafo que explican?
- ¿Cómo hago notas al pie?
- ¿Cómo compongo en columna y media, con una columna de texto ancha y una lateral estrecha?
- ¿Cómo añado a una apertura una línea de autor, una entradilla o un primer párrafo con capitular?
La respuesta corta
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
// (gotcha: side-box-starts-at-fence).
const gloss = (id, hue) => ({ id,
backgroundEnabled: false, // one device: a hairline over the gloss, in its colour
stripe: { enabled: true, side: 'top', width: pt(0.5), color: col(hue) },
padding: { top: mm(1.5), right: pt(0), bottom: pt(0), left: pt(0) },
// Cormorant SC draws lower case as small capitals: the title needs no textTransform.
titleStyle: { fontFamily: LABEL, fontWeight: 600, fontSize: pt(8.5),
letterSpacing: pt(0.3), color: col(hue), gap: mm(0.8) },
// Face and colours come from bodyText. A box body also inherits its 4 mm first-line
// indent, which a gloss sets back to 0.
body: { fontSize: pt(7.8), lineHeight: pt(10), textAlign: 'left',
firstLineIndent: pt(0) } });
const calloutStyles = [gloss('note', 'lawn'), gloss('context', 'jam')]; // words, history
Ingredientes
- Funciones
- Notas al margenColumna al margen para flotantesColumna y mediaMárgenes simétricosRecuadrosSuperíndices y subíndicesAperturas diseñadasBanda de capítulo a todo el anchoTextos, filetes y cajas en los diseños de páginaImágenes en los diseños de páginaAnclaje de elementos de diseñoCapitulares en las aperturasAtributos de títuloCabeceras y foliosCabeceras según el tipo de páginaFiguras y tablas como recursosPaleta de color semánticaCorte de líneas óptimo (Knuth–Plass)Chips en línea
- También usa
- Notas al pieColor del papel
- Tipografía
- Unna, Rozha One, Cormorant SC (SIL OFL 1.1)
- Recursos
tea-table-1560.jpg- La mesa del té vista desde arriba, una acuarela (Generated With Diffusion Models, original)
Elaboración
#1 · Deja el corte exterior para las glosas
El código es la respuesta corta de arriba. En una disposición en columna y media, sideColumnPercent: 26 da a la columna lateral 33 de los 127 mm que hay entre márgenes, y al texto le quedan 89,5 mm después del medianil de 4,5 mm. Con sideColumnRole: 'floats' el texto de Carroll no entra en la columna lateral, que solo recibe lo que se coloca en ella con span: 'side'. Una nota al pie espera al pie de la columna, bajo un filete; en el margen, cada glosa queda a la altura de la línea que explica y las glosas no le quitan líneas a la columna de texto. Los dos estilos de glosa solo se diferencian en el color del filete y del título, así que el lector distingue una glosa sobre una palabra de otra sobre historia antes de leerla.
#2 · Refleja la página para que el canal siga al corte exterior
const PT = 25.4 / 72; // mm in a point
const [TRIM_W, TRIM_H] = [156, 234]; // mm
const [TOP, BOTTOM, INNER, OUTER] = [22, 22, 15, 14]; // mm: 38 lines of text
const page = { width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
backgroundColor: col('paper'),
// left is a recto's inner margin; mirror swaps the sides on a verso, and 'outer' moves
// the channel with them: right on a recto, left on a verso.
margins: { top: mm(TOP), bottom: mm(BOTTOM), left: mm(INNER), right: mm(OUTER),
mirror: true } };
const CONTENT_W = TRIM_W - INNER - OUTER; // 127 mm
const SIDE_W = CONTENT_W * layout.sideColumnPercent / 100; // 33 mm: the glosses' measure
const TEXT_W = CONTENT_W - SIDE_W - layout.gutterWidth.value;
Con mirror: true los márgenes se intercambian en cada página par, y sideColumnSide: 'outer' lleva el canal con ellos, así que las glosas bajan por la derecha de las páginas 81 y 83 y por la izquierda de la 82. Los márgenes de 22 mm arriba y abajo dejan 190 mm, sitio para 38 líneas de 14 pt, y cada glosa empieza en una línea de esa misma rejilla.
#3 · Pon cada glosa antes del párrafo que explica
const bodyText = { // justified and hyphenated (en-us) by default
// Copy-fitted to the 89.5 mm column: at 9.5 pt '“Have some wine,” the March Hare said in
// an encouraging tone.' fits one line. At 10.4 pt every measure from 77 to 93 mm left
// it a short last line: 'couraging tone.', 'aging tone.', 'ing tone.' or 'tone.'.
fontFamily: TEXT, fontSize: pt(9.5), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), firstLineIndent: mm(4),
// The chapter's first paragraph is set flush, though the fences of glosses a and b stand
// between the heading and it: a box that leaves the flow is not the block after a heading.
indentAfterHeading: false,
// Unna's space is narrow, 0.22 em. At the default 0.6 the line breaker set 'Alice felt
// dreadfully puzzled. The Hatter’s remark seemed to have' with its spaces at 0.69.
minWordSpacing: 0.75,
// The dictionary divides the heroine's name, 'said Al-' | 'ice indignantly' on page 81.
// The list keeps it whole wherever it stands; every other word is divided as before.
hyphenation: { exceptions: ['Alice'] } };
Un recuadro con span="side" en su valla :::callout sale del flujo y se coloca en el canal a la altura del bloque que lo sigue en el Markdown. Por eso el bloque de cada glosa va justo antes del párrafo que lleva su llamada, como en el ejemplo de abajo. Las glosas a y b acompañan al primer párrafo, con lo que sus bloques quedan entre el título y ese párrafo. Un recuadro que sale del flujo no cuenta como el bloque que sigue al título, así que indentAfterHeading: false deja igualmente ese párrafo sin sangría. El cuerpo está ajustado a la columna: a 9,5 pt, el párrafo que empieza «“Have some wine,”» cabe en una línea de 89,5 mm, y a 10,4 pt todas las medidas entre 77 y 93 mm le dejaban una última línea corta, como «ing tone.» o «tone.». El espacio entre palabras de Unna es estrecho, 0,22 em, y con el minWordSpacing por defecto, 0,6, una línea de la página 83 lo reducía al 0,69 de su anchura; con minWordSpacing: 0.75 esa línea ya no es posible. En la página 81 el diccionario partía el nombre de la protagonista, «Al-» e «ice»; ese párrafo va dentro de :::paragraphs{style="whole"}, un estilo con hyphenation: false, y su único corte es un guion opcional (U+00AD) escrito en «together».
:::callout{type="context" span="side" title="c · Hair"}
Tenniel drew Alice with long, loose hair. …
:::
“Your hair wants cutting,”:chip[^c^]{style="context"} said the Hatter. …#4 · Da a cada letra el color de su glosa
// A letter in the text is a chip named after its gloss's type, :chip[^a^]{style="note"}:
// the Markdown has no mark for coloured text, and a chip style sets a colour. With no
// fill, outline, padding or gap the chip adds no width, so the lines break as they would
// with a plain ^a^.
const letter = (id, hue) => ({ id, backgroundEnabled: false, borderWidth: pt(0),
paddingX: pt(0), gap: pt(0), color: col(hue), bold: true });
const chipStyles = [letter('note', 'lawn'), letter('context', 'jam')];
El Markdown no tiene marca para el texto en color, pero un estilo de chip sí fija un color de texto, así que cada llamada es un chip cuyo estilo se llama igual que el tipo de su glosa. :chip[^c^]{style="context"} imprime una c roja, el mismo rojo del filete y del título de la glosa c. Sin fondo, contorno, relleno ni separación, el chip no añade anchura y cada línea se corta donde se cortaba con un ^c^ sin más.
#5 · Abre el capítulo bajo la mesa del té
const HEADPIECE = 72; // mm: the depth of the painting at the head of the page
const HEADNOTE = { size: 9.8, lead: LEAD }; // pt: the headnote keeps the body's leading
const CAPS = { text: 0.597, initial: 0.56 }; // cap heights, em: Unna and Rozha One
// The initial's size: its capital runs from the first line's cap height down to the
// last baseline it spans. At the default size it stops short of the first line's capitals.
const dropSize = (lines) => pt(((lines - 1) * HEADNOTE.lead + CAPS.text * HEADNOTE.size)
/ CAPS.initial);
const below = (id, y, width) => ({ anchor: { to: `#${id}`, edge: 'below' },
offset: { y: mm(y) }, size: { width } });
// The opener reserves the height of its lowest element, rounded up to the grid, and the
// heading's default bottom margin adds one blank line: with a four-line headnote the
// text starts on line 23. The kicker, the title and the headnote hang below the painting.
const opener = { enabled: true, slot: { elements: [
// An image element draws a resource without number or caption. It hangs from the
// trim's corner, over the top margin and both side margins.
{ kind: 'image', id: 'headpiece', resourceId: 'tea-table',
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: mm(TRIM_W) } } },
// The numeral comes from the heading line,
// # A Mad Tea-Party {num="VII" headnote="…" …}: the excerpt stands alone, so
// {chapterNumber} would count its one heading and print 1.
{ kind: 'text', id: 'kicker', content: 'Chapter {attr.num}', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(9), letterSpacing: pt(2), textTransform: 'uppercase',
color: col('jam'), align: 'left',
placement: { anchor: { to: 'container', edge: 'top-left' },
offset: { y: mm(HEADPIECE - TOP + 8) } } }, // 8 mm under the painting's foot
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY,
fontSize: pt(40), lineHeight: 1.05, color: col('ink'), align: 'left', // wraps when longer
placement: below('kicker', 2, 'fill') },
// The drop cap opens the headnote, the editor's voice, italic and ragged; Carroll's
// text opens in the flow, justified.
{ kind: 'text', id: 'headnote', content: '{attr.headnote}', fontFamily: TEXT,
italic: true, fontSize: pt(HEADNOTE.size),
lineHeight: pt(HEADNOTE.lead), color: col('ink'),
align: 'left',
dropCap: { lines: 2, fontFamily: DISPLAY, fontSize: dropSize(2), color: col('lawn'),
gap: mm(1.5) },
placement: below('title', 5, mm(TEXT_W)) },
// The note on this edition stands in the channel, level with the headnote's top.
{ kind: 'text', id: 'edition-label', content: 'This edition', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(8.5), letterSpacing: pt(0.3), color: col('muted'),
align: 'left', placement: { anchor: { to: '#headnote', edge: 'right-of' },
offset: { x: layout.gutterWidth }, size: { width: mm(SIDE_W) } } },
{ kind: 'text', id: 'edition', content: '{attr.source}', fontFamily: TEXT,
fontSize: pt(7.5), lineHeight: pt(10), color: col('muted'), align: 'left',
placement: { anchor: { to: '#edition-label', edge: 'below' }, offset: { y: mm(0.8) },
size: { width: mm(SIDE_W) } } },
] } };
La ranura de diseño del título ocupa toda la página para que la acuarela pueda llegar al corte. El antetítulo, el título y la entradilla cuelgan bajo la acuarela, y la apertura reserva hasta el más bajo de ellos, con la altura redondeada a la rejilla; el margen inferior que el título lleva por defecto añade una línea en blanco. Con una entradilla de cuatro líneas el texto empieza en la línea 23, y una quinta lo bajaría a la 24. El número, la entradilla y la nota sobre esta edición salen de atributos del título, {num="VII" headnote="…" source="…"}. El número se toma de ahí porque {chapterNumber} imprimiría 1 en un fragmento que es un documento aparte. La capitular abre la entradilla del editor, en cursiva y en bandera, y el texto de Carroll empieza justificado debajo, ya en el flujo. dropSize() calcula el cuerpo de la capitular para que su parte superior quede a la altura de las mayúsculas de la primera línea de la entradilla.
#6 · Da a cada glosa el color de lo que explica
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
El verde césped marca las glosas sobre palabras, dichos y chistes, y el rojo mermelada las de personas, fechas e historia del texto. Basta un valor nuevo en jam, en el mismo objeto palette, para recolorear a la vez las glosas de historia, sus llamadas y el antetítulo; la acuarela de arriba se eligió por ese mismo verde césped y ese rojo mermelada.
La receta completa
// ═══ Postext Cookbook · Nº 032 · Annotated classic with margin glosses ════════════
// https://postext.dev/en/cookbook/annotated-classic-glosses
// Code: MIT · Text: Lewis Carroll (PD), glosses (CC BY 4.0) · Headpiece: diffusion models
// Fonts: Unna, Rozha One, Cormorant SC (SIL OFL 1.1) · Needs postext ≥ 1.28.0
// The mad tea-party as an annotated edition: the text keeps to one column, and its glosses stand
// in the outer margin beside the lines they explain, changing sides with the spread.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en')
const RECIPE = 'annotated-classic-glosses';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a lawn green and a jam red on cream paper
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
// #endregion
const [TEXT, DISPLAY, LABEL] = ['Unna', 'Rozha One', 'Cormorant SC'];
const LEAD = 14; // body leading in pt: the grid of every page
// #region answer: a float-only channel at the fore-edge, and two gloss styles for it
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
El script.js compuesto funciona tal cual: pégalo como script de módulo en cualquier página o abre la receta en CodePen. Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)
Variantes
#Deja las glosas a la derecha en todas las páginas
Para una edición que se lee página a página en pantalla, desactiva los márgenes simétricos: 'outer' pasa a ser el borde derecho de todas las páginas, y las cabeceras no se mueven, porque van ancladas a los bordes de la página.
- mirror: true } };
+ mirror: false } };#Lleva las notas largas al pie de la página
Escribe como nota al pie la que no quepa en el margen, con [^1] en el texto y su definición [^1]: bajo el párrafo: Postext la compone al pie de la columna de texto, a 89,5 mm de ancho y bajo un filete corto, y las glosas conservan el canal. Notas al pie de la columna que las cita muestra cómo dar estilo a esas notas.
Errores frecuentes
Error frecuente
Un recuadro lateral empieza a la altura del bloque que sigue a su valla
En postext 1.4.1, un recuadro con span: 'side' se coloca en la columna lateral a la altura a la que ha llegado el texto en su valla, en la siguiente línea de la rejilla y debajo de los recuadros que ya haya. Pon la valla de una glosa justo antes del párrafo que explica: si va después, la glosa empieza junto al párrafo siguiente. Un recuadro que pasaría del pie de la columna sube hasta que su pie coincide con el de la columna, si el recuadro de encima le deja sitio; si aun así no cabe, espera a la columna lateral de la página siguiente. Notas al margen →
- Las glosas se apilan en el orden del Markdown, una debajo de otra, así que una glosa larga empuja hacia abajo a la siguiente. En la página 81 las dos llamadas caen en la segunda línea del primer párrafo: la glosa a empieza a la altura del párrafo y la b a continuación, cinco líneas por debajo de su llamada. Donde las llamadas queden cerca, escribe glosas breves.
Créditos
- Receta
- Ignacio Ferro
- Texto
- Alice’s Adventures in Wonderland (1865), comienzo del capítulo VII, «A Mad Tea-Party» · Lewis Carroll · dominio público
- La entradilla, las ocho glosas y la nota sobre esta edición · Ignacio Ferro · CC BY 4.0
- Imágenes
- La mesa del té vista desde arriba, una acuarela · Generated With Diffusion Models · original
- Fuentes
- Unna (SIL OFL 1.1) · Rozha One (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)
- Código
- MIT, como Postext
Editar este texto ↗ (se abre en una nueva pestaña)Carpeta de la receta en GitHub ↗ (se abre en una nueva pestaña)


