Skip to main content
Recipe number 144

Cookbook · Chapter 11 · Comics & manga

One set of panels, three page splits

Five comic panels laid out under three split trees: the split attribute of :::page cuts the page, and each picture's safe area keeps its subject in any cell.

On this page
Genre
Comics
Output
Canvas · PDF
Postext
Tested with Postext 1.65.0
Needs ≥ 1.25.0 · postext-pdf ≥ 1.25.0
Licence
Updated 10 Oct 2026
Code MIT · Text CC BY 4.0

pp. 2–3 of 4

  • Trim 168 × 259 mm
  • 1 column
  • Comic Neue 10.5/15
  • Bangers
  • 4 pages
  • Level
  • Postext 1.65.0
  • Laid out in 393 ms
  • 132 lines of code

In short

A comic page drawn once and laid out three ways. The same five pictures and the same dialogue fill three different panel grids, and every picture is cropped again to fit its new panel.

What you'll build

A layout proof for one page of a comic, The Porthcove Light: a cover sheet and the same page in three plans, for the author to choose from. The five pictures (Maya climbing to the lighthouse, her grandfather at a dead radio, Maya pointing at the floor, the cat asleep on the cable, the lamp lit at night) and the six lines of lettering never change; only the split of each :::page does. Every picture is cropped again for its cell and every balloon placed again around its speaker. The trim is an American comic book, 168 × 259 mm, and the proof comes in ten editions, each lettered in its own language.

This recipe answers

  • How do I divide a page into comic panels?
  • How do I keep a face in view when a panel crops the picture?
  • How do I re-letter a comic in another language?

The short answer

script.js · lines 48–65in full code
// Every :::page fills the type area; its split attribute cuts it into cells and its ::panel
// lines fill them in reading order (rows top to bottom, columns from the start side):
//   :::page{split="30 / 35 [* | * | *] / *"}    three tiers, the middle one in three
//   :::page{split="60 [* / *] | * [* / * / *]"} two columns, then each column in tiers
//   :::page{split="30 [30 | 20 | *] / *"}       a 30 % tier cut 30 | 20 | rest, then the rest
// A size is a percentage of the parent cell, * shares what is left, [ … ] cuts that cell
// on the other axis. A panel with inset="x y w h" sits over the panel before it.
const comics = {
  gutter: { horizontal: mm(4), vertical: mm(3) }, // between tiers, between panels in a tier
  panel: { borderWidth: pt(1), borderColor: col('ink'), background: col('paper') },
  lettering: { fontFamily: LETTERING, fontSize: pt(8), color: col('ink'), inset: mm(1) },
  balloonStyles: [
    { id: 'speech', stroke: col('ink') },
    { id: 'caption', fill: col('caption'), stroke: col('ink') },
    { id: 'sfx', fontFamily: SFX, color: col('accent'), haloColor: col('paper') },
  ],
  runningHeads: true, // a comic page has no running head unless asked: here, its folio
};

The comic: a frame, gutters, a panel border, and a page per split

Ingredients

Type
Comic Neue, Bangers, Zen Antique, Dela Gothic One, ZCOOL KuaiLe, ZCOOL QingKe HuangYou, Playpen Sans Arabic, Lalezar (SIL OFL 1.1)
Assets
  • lh-arrive.jpg
  • lh-beam.jpg
  • lh-biscuit.jpg
  • lh-maya.jpg
  • lh-radio.jpg
  • Panel picture: Maya arrives at the lighthouse (Generated With Diffusion Models, original)
  • Panel picture: Tomás at the radio (Generated With Diffusion Models, original)
  • Panel picture: Maya finds the problem (Generated With Diffusion Models, original)
  • Panel picture: Biscuit asleep on the cable (Generated With Diffusion Models, original)
  • Panel picture: the lamp lit at night (Generated With Diffusion Models, original)

Method

#1 · Cut the page with a split tree

The code is the short answer above. A :::page fills the type area, 144 × 227 mm here, and its split attribute cuts it. / separates rows, | separates columns, each size is a percentage of the cell it cuts, * shares what is left, and a bracket cuts that cell again on the other axis (splitting the page). Plan C, 30 [30 | 20 | *] / *, makes a tier 30% deep, cuts it into cells 30% and 20% wide plus the rest, and leaves one tall cell under it. The gutters straddle each line: 4 mm between tiers, 3 mm between panels in a tier. The ::panel lines fill the cells in reading order, rows from the top and columns from the start side.

Plan C: the 30 | 20 | rest tier, with the cat as an inset over the third panel.

#2 · Give each picture a safe area

script.js · lines 182–293in full code
// From the art manifest; fractions of each picture, the same in every language. The safe
// area is what every crop keeps: Tomás alone, not his radio, so a cell a fifth of the page
// wide still shows him; the lighthouse and the gallery, not the boat, so a tall cell holds them.
const ART = {
  'lh-arrive': { width: 1100, height: 733, safeArea: { x: 0.22, y: 0.08, width: 0.4, height: 0.64 },
    anchors: [{ id: 'maya', x: 0.29, y: 0.52, head: { x: 0.27, y: 0.47 },
      face: { x: 0.22, y: 0.42, width: 0.12, height: 0.16 } },
    { id: 'biscuit', x: 0.4, y: 0.68, face: { x: 0.37, y: 0.64, width: 0.07, height: 0.08 } }],
    avoid: [{ x: 0.51, y: 0.09, width: 0.1, height: 0.43 }],
    alt: t({ en: 'A girl in a yellow raincoat walks up a coastal path towards a red-and-white '
      + 'lighthouse, a fat orange cat ahead of her.',
      es: 'Una niña con chubasquero amarillo sube por un camino de costa hacia un faro rojo y '
        + 'blanco, con un gato naranja gordo delante.',
      ca: 'Una nena amb impermeable groc puja per un camí de costa cap a un far vermell i blanc, '
        + 'amb un gat taronja gras al davant.',
      zh: '一个穿黄色雨衣的女孩沿着海边小路走向红白相间的灯塔,一只胖胖的橘猫走在前面。',
      ar: 'فتاة بمعطف مطر أصفر تصعد دربًا ساحليًا نحو منارة حمراء وبيضاء، وأمامها قط برتقالي سمين.',
      ja: '黄色いレインコートの女の子が、赤と白の灯台へ続く海辺の小道をのぼっていく。前を太ったオレンジ色の猫が歩く。',
      pt: 'Uma menina de capa de chuva amarela sobe um caminho à beira-mar rumo a um farol '
        + 'vermelho e branco, com um gato laranja gordo à frente.',
      fr: 'Une fillette en ciré jaune monte un sentier côtier vers un phare rouge et blanc, '
        + 'précédée d’un gros chat roux.',
      de: 'Ein Mädchen in gelbem Regenmantel geht einen Küstenpfad zu einem rot-weißen '
        + 'Leuchtturm hinauf, eine dicke rote Katze vor ihr.',
      it: 'Una bambina con l’impermeabile giallo sale per un sentiero costiero verso un faro '
        + 'bianco e rosso, preceduta da un grosso gatto rosso.' }) },
  'lh-radio': { width: 1000, height: 1000,
    safeArea: { x: 0.27, y: 0.38, width: 0.24, height: 0.3 },
    anchors: [{ id: 'tomas', x: 0.345, y: 0.52, head: { x: 0.38, y: 0.44 },
      face: { x: 0.29, y: 0.4, width: 0.16, height: 0.18 } }],
    avoid: [{ x: 0, y: 0.44, width: 0.22, height: 0.26 }],
    alt: t({ en: 'The old keeper, white-bearded, in a navy sweater and cap, taps a valve radio '
      + 'with the microphone in his hand.',
      es: 'El viejo farero, de barba blanca, jersey azul marino y gorra, golpea una radio de '
        + 'válvulas con el micrófono en la mano.',
      ca: 'El vell faroner, de barba blanca, jersei blau marí i gorra, pica una ràdio de vàlvules '
        + 'amb el micròfon a la mà.',
      zh: '白胡子的老守塔人穿着藏青色毛衣、戴着帽子,手握话筒,敲着一台电子管收音机。',
      ar: 'حارس المنارة العجوز بلحيته البيضاء وكنزته الكحلية وقبعته ينقر على مذياع قديم '
        + 'والميكروفون في يده.',
      ja: '白いひげの老灯台守が、紺のセーターに帽子姿でマイクを握り、真空管ラジオをたたいている。',
      pt: 'O velho faroleiro, de barba branca, suéter azul-marinho e boné, dá batidinhas num '
        + 'rádio valvulado com o microfone na mão.',
      fr: 'Le vieux gardien, barbe blanche, pull bleu marine et casquette, tapote une radio à '
        + 'lampes, le micro à la main.',
      de: 'Der alte Wärter mit weißem Bart, marineblauem Pullover und Mütze klopft auf ein '
        + 'Röhrenradio, das Mikrofon in der Hand.',
      it: 'Il vecchio guardiano, barba bianca, maglione blu e berretto, picchietta su una radio a '
        + 'valvole con il microfono in mano.' }) },
  'lh-maya': { width: 1100, height: 1100, safeArea: { x: 0.25, y: 0.27, width: 0.41, height: 0.68 },
    anchors: [{ id: 'maya', x: 0.54, y: 0.565, head: { x: 0.5, y: 0.3 },
      face: { x: 0.4, y: 0.33, width: 0.24, height: 0.29 } }],
    avoid: [{ x: 0.27, y: 0.73, width: 0.25, height: 0.22 }],
    alt: t({ en: 'Close-up of Maya frowning at the floor and pointing down.',
      es: 'Primer plano de Maya, que frunce el ceño mirando al suelo y señala hacia abajo.',
      ca: 'Primer pla de la Maya, que arrufa les celles mirant a terra i assenyala avall.',
      zh: '玛雅的特写:她皱着眉头看着地板,手指向下指。',
      ar: 'لقطة قريبة لمايا وهي تعقد حاجبيها ناظرةً إلى الأرض وتشير إلى أسفل.',
      ja: 'マヤのアップ。眉をひそめて床を見つめ、下を指さしている。',
      pt: 'Close de Maya, de testa franzida, olhando para o chão e apontando para baixo.',
      fr: 'Gros plan sur Maya, sourcils froncés, qui fixe le sol et pointe le doigt vers le '
        + 'bas.',
      de: 'Nahaufnahme von Maya, die mit gerunzelter Stirn auf den Boden blickt und nach unten '
        + 'zeigt.',
      it: 'Primo piano di Maya, accigliata, che fissa il pavimento e indica in basso.' }) },
  'lh-biscuit': { width: 1000, height: 1000,
    safeArea: { x: 0.58, y: 0.25, width: 0.42, height: 0.33 },
    anchors: [{ id: 'biscuit', x: 0.72, y: 0.355, head: { x: 0.73, y: 0.32 },
      face: { x: 0.64, y: 0.27, width: 0.2, height: 0.18 } }],
    avoid: [{ x: 0.93, y: 0.28, width: 0.07, height: 0.24 },
      { x: 0, y: 0.72, width: 0.4, height: 0.1 }],
    alt: t({ en: 'Under the desk the fat orange cat sleeps on his back, right on top of the black '
      + 'radio cable.',
      es: 'Bajo la mesa, el gato naranja gordo duerme panza arriba justo encima del cable negro '
        + 'de la radio.',
      ca: 'Sota la taula, el gat taronja gras dorm panxa enlaire just a sobre del cable negre de '
        + 'la ràdio.',
      zh: '桌子底下,胖橘猫四脚朝天地睡着,正好压在收音机的黑色电线上。',
      ar: 'تحت المكتب ينام القط البرتقالي السمين على ظهره فوق سلك المذياع الأسود تمامًا.',
      ja: '机の下で、太ったオレンジ色の猫がラジオの黒いコードの真上にあおむけで眠っている。',
      pt: 'Debaixo da mesa, o gato laranja gordo dorme de barriga para cima bem em cima do cabo '
        + 'preto do rádio.',
      fr: 'Sous le bureau, le gros chat roux dort sur le dos, juste sur le câble noir de la '
        + 'radio.',
      it: 'Sotto la scrivania, il grosso gatto rosso dorme a pancia in su, proprio sopra il cavo '
        + 'nero della radio.',
      de: 'Unter dem Schreibtisch schläft die dicke rote Katze auf dem Rücken, genau auf dem '
        + 'schwarzen Kabel des Funkgeräts.' }) },
  'lh-beam': { width: 1200, height: 800, safeArea: { x: 0.15, y: 0.01, width: 0.25, height: 0.3 },
    anchors: [{ id: 'maya', x: 0.235, y: 0.15,
      face: { x: 0.21, y: 0.11, width: 0.05, height: 0.07 } },
      { id: 'tomas', x: 0.3, y: 0.145, face: { x: 0.28, y: 0.11, width: 0.04, height: 0.06 } }],
    avoid: [{ x: 0.79, y: 0.55, width: 0.08, height: 0.09 }],
    alt: t({ en: 'Night: the beam sweeps over a dark sea; Maya and her grandfather stand on the '
      + 'lantern gallery and a fishing boat shows its lights far out.',
      es: 'De noche, el haz barre un mar oscuro; Maya y su abuelo están en la galería de la '
        + 'linterna y a lo lejos se ven las luces de un pesquero.',
      ca: 'De nit, el feix escombra un mar fosc; la Maya i el seu avi són a la galeria de la '
        + 'llanterna i lluny es veuen els llums d’un pesquer.',
      zh: '夜里,灯塔的光束扫过漆黑的海面;玛雅和外公站在灯室外的回廊上,远处一艘渔船亮着灯。',
      ar: 'ليلًا يمسح الشعاع بحرًا مظلمًا، ومايا وجدّها واقفان على شرفة الفانوس، وفي البعيد قارب '
        + 'صيد بأضوائه.',
      ja: '夜。光の帯が暗い海をなでる。マヤと祖父は灯室の回廊に立ち、沖には漁船の明かりが見える。',
      pt: 'À noite, o facho varre um mar escuro; Maya e o avô estão na galeria da lanterna e, ao '
        + 'longe, aparecem as luzes de um barco de pesca.',
      fr: 'La nuit, le faisceau balaie une mer sombre ; Maya et son grand-père se tiennent sur '
        + 'la galerie de la lanterne et, au large, un bateau de pêche montre ses feux.',
      de: 'Nacht: Der Lichtstrahl streicht über ein dunkles Meer; Maya und ihr Großvater stehen '
        + 'auf der Galerie der Laterne, und weit draußen zeigt ein Fischerboot seine Lichter.',
      it: 'Di notte il fascio di luce spazza un mare scuro; Maya e suo nonno sono sulla balconata '
        + 'della lanterna e, al largo, si vedono le luci di un peschereccio.' }) },
};

Each picture is drawn once and cropped to fill whatever cell it lands in. The safe area is the part every crop keeps whole (panels and art). The radio picture's safe area is the keeper alone, 24% of its width, so the 26 mm cell of plan C shows him from cap to boots and drops the radio; the wide cells of plans A and B show both. A cell whose shape cannot hold a safe area letterboxes the picture and the build warns (comicPanelLetterbox). The anchors mark each speaker's mouth and face in the same fractions, so the tails find the speakers in every crop.

#3 · Lay one panel over another

Plan C's split makes four cells for five panels. The cat goes in with inset="50 50 46 46": a panel 46% wide and 46% deep, placed at 50%, 50% of the panel before it, Maya's. An inset takes no cell, so the panels after it keep their places, and it is read right after the panel it covers.

#4 · Letter ten editions from one layout

script.js · lines 35–44in full code
// The lettering and sound-effect faces of each edition: the engine's defaults, but for Chinese
// two ZCOOL faces drawn for cartoons instead of Noto Sans SC. content.<lang>.md holds the words
// of each edition under the same speaker ids; Japanese balloons are set vertically, and the
// Japanese and Arabic editions, read right to left, mirror the order of the panels in every row.
const [LETTERING, SFX] = t({
  en: ['Comic Neue', 'Bangers'], es: ['Comic Neue', 'Bangers'], ca: ['Comic Neue', 'Bangers'],
  ja: ['Zen Antique', 'Dela Gothic One'], zh: ['ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou'],
  ar: ['Playpen Sans Arabic', 'Lalezar'], pt: ['Comic Neue', 'Bangers'],
  fr: ['Comic Neue', 'Bangers'], de: ['Comic Neue', 'Bangers'], it: ['Comic Neue', 'Bangers'],
});

The split, the pictures, the crops and the anchors are the same in every language; content.<lang>.md holds only the words, under the same speaker ids (maya, tomas). The Japanese edition sets its balloons vertically, eight characters to the column, and drops the final 。; it reads right to left, like the Arabic one, so each row's panels are mirrored while the pictures are not. The lettering size stays 8 pt in every edition: a longer line makes a bigger balloon, never smaller type (lettering).

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 144 · One set of panels, three page splits ═══════════════
// https://postext.dev/en/cookbook/comic-page-splitters
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Comic Neue, Bangers and the faces of five editions (OFL) · Needs postext ≥ 1.25.0
//
// A layout proof for one page of a comic: the same five pictures and the same lines of
// dialogue laid out under three `split` trees. Each picture carries a safe area, so its subject
// stays in view whether its cell is wide, tall or square, and the lettering is placed again
// around the speakers' anchors on every page and in every language.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: 'en' | 'es' | 'ca' | 'zh' | 'ar' | 'ja' | 'pt' | 'fr' | 'de' | 'it'
const RECIPE = 'comic-page-splitters';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the night sea, the lighthouse red and the yellow of the captions
const palette = {
  ink: '#1b2430', // panel borders, lettering and text: a blue-black
  accent: '#b8322a', // the lighthouse red: the proof's labels
  caption: '#f4e7bf', // caption boxes, an old-paper yellow
  muted: '#5f6873', // folios and the imprint
  paper: '#fdfbf6',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
  ...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
  { id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion

// #region editions: one comic, six editions, each lettered in faces for its script
// The lettering and sound-effect faces of each edition: the engine's defaults, but for Chinese
// two ZCOOL faces drawn for cartoons instead of Noto Sans SC. content.<lang>.md holds the words
// of each edition under the same speaker ids; Japanese balloons are set vertically, and the
// Japanese and Arabic editions, read right to left, mirror the order of the panels in every row.
const [LETTERING, SFX] = t({
  en: ['Comic Neue', 'Bangers'], es: ['Comic Neue', 'Bangers'], ca: ['Comic Neue', 'Bangers'],
  ja: ['Zen Antique', 'Dela Gothic One'], zh: ['ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou'],
  ar: ['Playpen Sans Arabic', 'Lalezar'], pt: ['Comic Neue', 'Bangers'],
  fr: ['Comic Neue', 'Bangers'], de: ['Comic Neue', 'Bangers'], it: ['Comic Neue', 'Bangers'],
});
// #endregion

// #region answer: the comic: a frame, gutters, a panel border, and a page per split
// Every :::page fills the type area; its split attribute cuts it into cells and its ::panel

The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)

Variations

#Slant the middle tier

A size written 30~40 runs that cell's far gutter from 30% at one end to 40% at the other. Slanted cells lose their rounded corners.

-:::page{split="30 / 35 [* | * | *] / *"}
+:::page{split="30 / 35 [30~40 | * | *] / *"}

#Mirror the art in the right-to-left editions

Pictures keep their handedness by default. A comic drawn without lettering or clocks can follow the reading direction.

 const comics = {
+  mirrorArt: true, // pictures flip in a right-to-left edition
   gutter: { horizontal: mm(4), vertical: mm(3) },

Pitfalls

  • A cell a fifth of the page wide holds about four words a line at 8 pt, and in plan C the keeper's face is in the middle of his: his two balloons about the storm are deeper than the room above or below it. There the first of the two lines carries break (tomas{break}:), so the pair may cross the gutter into Maya's panel; the engine keeps the second balloon after the first and never lets it run into the page margin. Without break the build warns comicBalloonOverflow.
  • A tighter safe area gives more cells a clean crop, but whatever lies outside it may be cut: the boots in plan A's first tier, the radio in plan C.

Credits

Text
Original prose, CC BY 4.0
Images
  • Panel picture: Maya arrives at the lighthouse · Generated With Diffusion Models · original
  • Panel picture: Tomás at the radio · Generated With Diffusion Models · original
  • Panel picture: Maya finds the problem · Generated With Diffusion Models · original
  • Panel picture: Biscuit asleep on the cable · Generated With Diffusion Models · original
  • Panel picture: the lamp lit at night · Generated With Diffusion Models · original
Fonts
Comic Neue (SIL OFL 1.1) · Bangers (SIL OFL 1.1) · Zen Antique (SIL OFL 1.1) · Dela Gothic One (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1) · ZCOOL QingKe HuangYou (SIL OFL 1.1) · Playpen Sans Arabic (SIL OFL 1.1) · Lalezar (SIL OFL 1.1)
SandboxPDF