跳到主要内容
食谱编号154

排版食谱 · 第11章 · 漫画与连环画

横跨两页的一页漫画

带 spread 标记的 :::page 把一棵分格树铺在相对的两页上:全景图跨过书脊,下面一排在折缝处分开。

本页内容
类型
漫画
输出
Canvas · PDF
难度
中级
Postext
已用Postext 1.65.0测试
需要≥ 1.34.0 · postext-pdf ≥ 1.34.0
许可证
更新于2026年10月16日
代码MIT · 文本CC BY 4.0

页码2–3 · 第1–2页,共2页

  • 成品尺寸230 × 300 mm
  • 1栏
  • Noto Sans SC 11/15
  • 2页
  • 难度
  • Postext 1.65.0
  • 排版用时390 ms
  • 141行代码

简单来说

把一则漫画排在相对的两页上,像一整页那样:一幅人山人海的市场长图横跨书的中缝,下面是三个画格。

成品一览

第 152 号那本画册里的第二个故事《爷爷!》,讲在相对的两页上。十二月的一个星期六,市场里挤满了人,萝拉和爷爷走散了。跨页的上半部分是一整幅 432 毫米宽的全景图:小小的萝拉在最左边,帕科在最右边找她,两人之间是市场的过道,正好通到折缝。下面三格:萝拉孤零零地站在一堆大人的腿中间,帕科站在水果箱上吹口哨,最后祖孙重逢,贝雷帽飞上了天。分格只写一次,覆盖两页,所以全景图跨过书脊,下排的格间距正好落在折缝上。西班牙语是原文;英语、加泰罗尼亚语、中文、阿拉伯语、日语、葡萄牙语、法语、德语和意大利语版在同一个跨页上嵌字。

这道食谱解答

  • 怎样把一页漫画铺满跨页?

简短回答

script.js · 第40–53行在完整代码中
// The content writes :::page{spread split="55 / * [25 | 25 | *]"}: one frame from the verso's
// outer margin to the recto's (the inner margins drop out), split as one page. The panorama
// crosses the spine; the line at 50 % of the lower tier is the spine itself, so its gutter
// straddles the fold and no panel is cut by it.
const comics = {
  gutter: { horizontal: mm(5), vertical: mm(4) }, // 2 mm of white on each side of the fold
  panel: { borderWidth: pt(0.75), borderColor: col('ink'), background: col('paper') },
  lettering: { fontFamily: LETTER, fontSize: pt(LATIN ? 9.5 : 8.5), lineHeight: 1.1,
    color: col('ink') },
  runningHeads: true, // folios on both halves
};
// A spread opens on a verso, an even page. Page 1 of a document is a recto, so the engine
// would leave it blank and start on page 2; this episode continues an album at page 2.
const continuation = { pageIndexOffset: 1, pageNumbering: { startAt: 2 } };

用料

类型
Patrick Hand, Bangers, Noto Sans SC, ZCOOL KuaiLe, Zen Antique, Dela Gothic One, Playpen Sans Arabic, Lalezar(SIL OFL 1.1)
素材
  • ds1-1900.jpg
  • ds2.jpg
  • ds3.jpg
  • ds4.jpg
  • Panorama of the crowded market hall: tiny Lola stands lost on the far left; far right, her grandfather searches the crowd. (Generated With Diffusion Models, 原创)
  • Lola, tearful, stands among grown-ups' legs and shopping bags. (Generated With Diffusion Models, 原创)
  • Paco stands on a fruit crate and whistles through his fingers; shoppers turn to look. (Generated With Diffusion Models, 原创)
  • Lola leaps into her grandfather's arms; his beret flies off and the stallholders smile. (Generated With Diffusion Models, 原创)

做法

#1 · 两页共用一套分格

代码就是上面的简短回答。整则漫画是一个带 spread 标记的指令:

:::page{spread split="55 / * [25 | 25 | *]"}
::panel{art=ds1}
caption: 十二月的一个星期六,市场里挤得水泄不通。
lola: 爷爷?
paco{shout}: 萝拉?萝拉——!

画框从左页的外侧页边一直到右页的外侧页边;两页的内侧页边都去掉。第一排占高度的 55%,是一个跨过书脊的画格。第二排里,25 | 25 | * 把第一条线放在 25%,第二条放在 50%,也就是书脊本身:两个方形画格在偶数页,重逢的一格在奇数页。跨页从偶数页开始,而文档的第 1 页是奇数页,所以构建时传入 continuation: { pageIndexOffset: 1 }:这一集从画册的第 2 页接着排,前面不需要空白页。

#2 · 够铺满两页的全景图

script.js · 第148–238行在完整代码中
// The panorama is 1,900 px wide: across the 432 mm of the spread it prints at about 112 dpi.
const box = ([x, y, width, height]) => ({ x, y, width, height });
const who = (id, x, y, head, face) => ({ id, x, y,
  ...(head && { head: { x: head[0], y: head[1] } }), ...(face && { face: box(face) }) });
const ART = {
  ds1: { width: 1900, height: 633, safeArea: box([.03, .27, .93, .53]),
    alt: t({ en: 'Panorama of the crowded market hall: tiny Lola stands lost on the far left; '
        + 'far right, her grandfather searches the crowd.',
      es: 'Panorámica del mercado lleno de gente: a la izquierda del todo, Lola, '
        + 'diminuta, está perdida; a la derecha del todo, su abuelo la busca entre la multitud.',
      ca: 'Panoràmica del mercat ple de gent: a l’extrem esquerre, la Lola, petitíssima, '
        + 'està perduda; a l’extrem dret, el seu avi la busca entre la gentada.',
      zh: '拥挤的市场全景:最左边,小小的萝拉迷了路;最右边,她的爷爷在人群中寻找她。',
      ar: 'منظر واسع للسوق المزدحم: لولا الصغيرة تائهة في أقصى اليسار، وفي أقصى اليمين '
        + 'جدّها يبحث عنها بين الناس.',
      ja: '人でいっぱいの市場のパノラマ。左端に小さなローラが迷子になって立ち、右端では祖父が人ごみの中を探している。',
      pt: 'Panorama do mercado lotado: na ponta esquerda, a pequena Lola está perdida; na ponta '
        + 'direita, o avô a procura no meio da multidão.',
      fr: 'Panorama de la halle du marché bondée : tout à gauche, la petite Lola est perdue ; '
        + 'tout à droite, son grand-père la cherche dans la foule.',
      de: 'Panorama der vollen Markthalle: Ganz links steht die kleine Lola verloren da; ganz '
        + 'rechts sucht ihr Großvater die Menge ab.',
      it: 'Panoramica del mercato coperto pieno di gente: all’estrema sinistra la piccola Lola si '
        + 'è persa; all’estrema destra suo nonno la cerca tra la folla.' }),
    anchors: [
      who('lola', .065, .58, [.063, .55], [.045, .51, .04, .11]),
      who('paco', .925, .38, [.925, .34], [.9, .3, .05, .12]),
    ],
    faces: [box([.062, .305, .022, .055])], // the fishmonger behind Lola, who says nothing
  },
  ds2: { width: 1152, height: 1152, safeArea: box([.31, .08, .35, .62]),
    alt: t({ en: "Lola, tearful, stands among grown-ups' legs and shopping bags.",
      es: 'Lola, con lágrimas en los ojos, está de pie entre piernas de mayores y bolsas '
        + 'de la compra.',
      ca: 'La Lola, amb llàgrimes als ulls, és dreta entre cames de grans i bosses de la compra.',
      zh: '萝拉含着眼泪,站在大人们的腿和购物袋之间。',
      ar: 'لولا والدموع في عينيها واقفة بين سيقان الكبار وأكياس التسوّق.',
      ja: '涙ぐんだローラが、大人の足と買い物袋のあいだに立っている。',
      pt: 'Lola, com lágrimas nos olhos, está de pé entre pernas de adultos e sacolas '
        + 'de compras.',
      fr: 'Lola, les larmes aux yeux, se tient entre des jambes d’adultes et des sacs de '
        + 'courses.',
      de: 'Lola steht mit Tränen in den Augen zwischen Erwachsenenbeinen und Einkaufstaschen.',
      it: 'Lola, con le lacrime agli occhi, è in piedi tra gambe di adulti e borse della '
        + 'spesa.' }),
    anchors: [
      who('lola', .505, .24, [.48, .17], [.4, .1, .18, .19]),
    ],
  },
  ds3: { width: 1000, height: 1000, safeArea: box([.34, .07, .47, .23]),
    alt: t({ en: 'Paco stands on a fruit crate and whistles through his fingers; shoppers '
        + 'turn to look.',
      es: 'Paco, subido a una caja de fruta, silba con los dedos; la gente se vuelve a mirar.',
      ca: 'En Paco, enfilat a una caixa de fruita, xiula amb els dits; la gent es gira a mirar.',
      zh: '帕科站在水果箱上,用手指吹口哨;买东西的人都回过头来看。',
      ar: 'باكو واقف على صندوق فاكهة ويصفّر بأصابعه، والمتسوّقون يلتفتون لينظروا.',
      ja: 'パコが果物の木箱に乗って指笛を吹き、買い物客がふり返る。',
      pt: 'Paco, em cima de um caixote de frutas, assobia com os dedos; as pessoas se viram '
        + 'para olhar.',
      fr: 'Paco, debout sur une cagette de fruits, siffle avec ses doigts ; les clients se '
        + 'retournent.',
      de: 'Paco steht auf einer Obstkiste und pfeift auf den Fingern; die Leute drehen sich um.',
      it: 'Paco, in piedi su una cassetta della frutta, fischia con le dita; la gente si volta a '
        + 'guardare.' }),
    anchors: [
      who('paco', .5, .2, [.47, .14], [.38, .08, .17, .16]),
      who('sfx', .62, .17),
    ],
  },
  ds4: { width: 1200, height: 800, safeArea: box([.33, .05, .48, .57]),
    alt: t({ en: "Lola leaps into her grandfather's arms; his beret flies off and the "
        + "stallholders smile.",
      es: 'Lola salta a los brazos de su abuelo; la boina sale volando y los tenderos sonríen.',
      ca: 'La Lola salta als braços del seu avi; la boina surt volant i els paradistes somriuen.',
      zh: '萝拉扑进爷爷怀里;他的贝雷帽飞了出去,摊主们都笑了。',
      ar: 'لولا تقفز إلى ذراعي جدّها، وقبعته تطير، والباعة يبتسمون.',
      ja: 'ローラが祖父の腕に飛びこむ。ベレー帽が飛び、店の人たちがほほえむ。',
      pt: 'Lola pula nos braços do avô; a boina sai voando e os feirantes sorriem.',
      fr: 'Lola saute dans les bras de son grand-père ; son béret s’envole et les marchands '
        + 'sourient.',
      de: 'Lola springt ihrem Großvater in die Arme; seine Baskenmütze fliegt davon, und die '
        + 'Händler lächeln.',
      it: 'Lola salta in braccio al nonno; il basco gli vola via e i bancarellai sorridono.' }),
    anchors: [
      who('lola', .51, .27, [.47, .2], [.42, .14, .13, .19]),
      who('paco', .595, .31, [.62, .22], [.55, .14, .15, .22]),
    ],
    avoid: [box([.67, .06, .13, .22])],
  },

};

全景图是唯一印过折缝的画,432 × 144 毫米,所以用 1900 像素(380 KB);另外三幅是 1000 到 1200 像素。它的安全区是一条几乎横贯全宽的带子,两个说话人站在两端,分别在宽度的 6% 和 92% 处,远离书脊,因为装订会把那里的对话框吞掉。这幅画本来就把中间留给了没有人脸的过道,正好通向折缝。人群里满是不说话的脸:萝拉身后的鱼贩标在 faces 里,也就是不说话的人的脸的列表,她的第一个对话框便落在他旁边,绝不会压在他的脸或帽子上;日文版把竖排的对话框固定在那里(at="2.8% 37%")。

#3 · 画册的对话框

script.js · 第57–72行在完整代码中
comics.balloonStyles = [
  { id: 'speech', fill: col('balloon'), stroke: col('ink'), strokeWidth: pt(0.6) },
  { id: 'caption', fill: col('cartouche'), stroke: col('ink'), strokeWidth: pt(0.6),
    padding: em(0.45), aspect: 3.4 },
  { id: 'shout', fill: col('balloon'), stroke: col('ink'), burstPoints: 16, fontScale: 1.2 },
  { id: 'whisper', fill: col('balloon'), stroke: col('ink') },
  { id: 'sfx', fontFamily: DISPLAY, color: col('orange'), halo: pt(1.6), haloColor: col('ink'),
    fontScale: 3.2 },
];
comics.cast = [
  { id: 'lola', name: 'Lola' },
  { id: 'paco', name: t({ es: 'el abuelo Paco', en: 'Grandpa Paco', ca: "l'avi Paco",
    zh: '帕科爷爷', ar: 'الجد باكو', ja: 'パコおじいちゃん', pt: 'o vovô Paco', fr: 'papi Paco',
    de: 'Opa Paco',
    it: 'nonno Paco' }) },
];

对话框样式与第 152 号相同:白色对话框、淡黄色旁白框、帕科喊叫用的爆炸框、萝拉小声说话用的虚线框,口哨声用画册的拟声词字体,拉丁文版是 Bangers。cast 给 PDF 和 EPUB 提供每句台词前读出的人物名字。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 154 · One comic page across a double spread ═══════════════
// https://postext.dev/en/cookbook/comic-double-spread
// Code: MIT · Story: written for the recipe (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Patrick Hand, Bangers, the comic faces of each script (OFL) · Needs postext ≥ 1.34.0
// One split tree laid across two facing pages: a panorama runs over the spine, and the
// tier under it splits at the spine's gutter. Same album, same lettering as Nº 152.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage, defaultComicFont,
  defaultComicSfxFont,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

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

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the album's flat colours
const palette = {
  ink: '#1d1b19', // outlines, lettering, folios
  orange: '#d9601a', // the sound effect
  cartouche: '#fbe8a6', // narration boxes
  balloon: '#ffffff',
  muted: '#5f5a54', // the colophon
  paper: '#fffdf8',
};
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: 'orange (defaults)', value: { hex: palette.orange, model: 'hex' } },
];
// #endregion

const LOCALE = t({ es: 'es', en: 'en-gb', ca: 'ca', zh: 'zh-Hans', ar: 'ar', ja: 'ja',
  pt: 'pt-BR', fr: 'fr', de: 'de', it: 'it' });
const LATIN = ['es', 'en', 'ca', 'pt', 'fr', 'de', 'it'].includes(LANG);
const LETTER = LATIN ? 'Patrick Hand' : defaultComicFont(LOCALE); // mixed-case hand lettering
const DISPLAY = defaultComicSfxFont(LOCALE); // Bangers, Dela Gothic One, ZCOOL KuaiLe, Lalezar

// #region answer: one split across two facing pages, opened on a verso
// The content writes :::page{spread split="55 / * [25 | 25 | *]"}: one frame from the verso's
// outer margin to the recto's (the inner margins drop out), split as one page. The panorama
// crosses the spine; the line at 50 % of the lower tier is the spine itself, so its gutter
// straddles the fold and no panel is cut by it.
const comics = {
  gutter: { horizontal: mm(5), vertical: mm(4) }, // 2 mm of white on each side of the fold
  panel: { borderWidth: pt(0.75), borderColor: col('ink'), background: col('paper') },
  lettering: { fontFamily: LETTER, fontSize: pt(LATIN ? 9.5 : 8.5), lineHeight: 1.1,
    color: col('ink') },

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#让书从跨页开始

去掉 continuation,引擎会把第 1 页留成空白(角色为 blank),跨页仍然落在第 2、3 页。

-const continuation = { pageIndexOffset: 1, pageNumbering: { startAt: 2 } };
+const continuation = {};

常见问题

  • 对话框不会进入书脊两侧 8 毫米的带子,用 at 固定的也一样:站在折缝上的说话人,对话框会被推到一边。跨过书脊的画格里,说话人要离中间远一些。
  • 脸贴在一起的两个人物(拥抱、扭打),对话框不会压在他们身上,说话人自己也算在内。日语版和阿拉伯语版的跨页从右往左读,重逢那一格移到左页,右上角被飞起的贝雷帽占着;帕科的两个对话框放在他头旁边的市场上,而不是拥抱的人物身上。在图上标出两人的脸(face),引擎才看得出两张脸贴在一起。

致谢

文本
  • ¡Abuelo! (Grandpa!), a two-page comic written for this recipe, in six languages · Postext Cookbook · CC BY 4.0
图片
  • Panorama of the crowded market hall: tiny Lola stands lost on the far left; far right, her grandfather searches the crowd. · Generated With Diffusion Models · 原创
  • Lola, tearful, stands among grown-ups' legs and shopping bags. · Generated With Diffusion Models · 原创
  • Paco stands on a fruit crate and whistles through his fingers; shoppers turn to look. · Generated With Diffusion Models · 原创
  • Lola leaps into her grandfather's arms; his beret flies off and the stallholders smile. · Generated With Diffusion Models · 原创
字体
Patrick Hand (SIL OFL 1.1) · Bangers (SIL OFL 1.1) · Noto Sans SC (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1) · Zen Antique (SIL OFL 1.1) · Dela Gothic One (SIL OFL 1.1) · Playpen Sans Arabic (SIL OFL 1.1) · Lalezar (SIL OFL 1.1)
沙盒PDF