简单来说
一份虚构日报的八个版面。前四版是新闻,印在灰白色纸上;后面的财经版印在橙红色纸上,栏更窄,颜色也不一样。
成品一览
虚构日报《The Marrowick Ledger》的八个版面,开本为315 × 470 mm的柏林版。第1至4版是新闻,印在灰白色新闻纸上,分五栏,栏间有细线,每版有一个红色版名标签。从第5版起纸张变了。财经版印在橙红色纸上,财经版面一百多年来一直这样印:页面变成#f2d3c0,网格收窄为六栏,强调色从红色换成石油蓝,版名下面是一条当日收盘行情。版内有一个市场版,载有本市指数一年的走势、一张行业图和四张数据表,还有公司新闻和一个股价版。在Folio的3D视图里,两张对折的纸一张套一张,最后四版印在橙红色纸上。
这道食谱解答
- 怎样在3D阅读器里把报纸显示成对折的纸张,并把财经版印在鲑鱼色纸上?
- 怎样让封面、插页或图版使用与全书不同的纸张?
- 报纸版面怎么排:对开报纸分五栏,一张照片横跨两栏,一个新闻框横跨三栏?
- 怎样把书分成若干篇或部分,每篇有自己的颜色和隔页?
简短回答
// page.backgroundColor links to 'paper', so the section's palette, which turns 'paper' salmon,
// repaints every page of the section: the opener and the pages its copy runs on to.
const business = {
id: 'business',
advancedDesign: { enabled: true, slot: { elements: flagParts } },
// The swap: the page, flags, kickers, the folio line, chart marks and table heads follow.
palette: { paper: palette.salmon, accent: palette.petrol, tint: '#e6bfa8' },
// Six narrower columns, ruled as the news pages are.
layout: { layoutType: 'multiple', columnCount: 6, gutterWidth: mm(4) },
bodyStyle: { fontSize: pt(8.8), lineHeight: pt(LEAD) },
};
// The section front: the same style, with a bigger flag over the market close strip.
const front = () => ({ ...business, id: 'business-front', advancedDesign: { enabled: true, slot: {
elements: [depth(10),
text('title', 'Business', { fontFamily: 'Playfair Display', fontSize: pt(58), fontWeight: 900,
lineHeight: 1, color: col('accent') }, at('container', 'top-left', 0, -1)),
text('tag', FLAG, caps(9, 700, 'accent'),
at('#title', 'right-of', 5, 9)),
rule('top', 3, at('#title', 'below', 0, 2)),
...STRIP().flatMap(([name, value, change], i) => [ // the day's close, from the market data
text(`s${i}`, name, caps(7, 700, 'muted'), at('#top', 'below', (i * WIDE) / 6, 1.8)),
text(`v${i}`, value, sans(13, 700), at(`#s${i}`, 'below', 0, 0.6)),
text(`c${i}`, change, sans(9.5, 600, { color: col(change[0] === '+' ? 'accent' : 'muted') }),
at(`#v${i}`, 'right-of', 1.6, 1))]),
rule('under', 0.5, at('#depth', 'align-bottom', 0, -1.4))] } } });
// hook-up: headingStyles lists both, and the Markdown wraps pages 5–8 in
// :::paper{type="newsprint" shade="#faede6"} ← the stock Folio prints them on
// # Business {style="business-front"} … # Markets {style="business"} … :::
用料
- 功能
- 为一组页面换用纸张三栏及以上对折的报纸(Folio)报纸开本跨多栏的浮动体标题样式分节版式按篇配色纸张颜色设计过的章首页锚定设计元素书眉与页码栏间线横跨页面的框浮动框框内或正文中的分栏命名表格样式图的放置图就放在这里纸张、装订、台面与光照(Folio)
- 类型
- Source Serif 4, Playfair Display, Archivo Narrow(SIL OFL 1.1)
- 素材
apprentices-1536.jpgbakery-1536.jpgbarrier-1800.jpgcartoon-1280.jpgcranes-1800.jpgferry-1536.jpg- The tidal barrier in a storm (page 1) (Generated With Diffusion Models, CC BY 4.0)
- Apprentices welding in the shipyard (page 2) (Generated With Diffusion Models, CC BY 4.0)
- The island ferry leaving Skerra pier (page 3) (Generated With Diffusion Models, CC BY 4.0)
- The editorial cartoon (page 4) (Generated With Diffusion Models, CC BY 4.0)
- Container cranes at dawn (page 5) (Generated With Diffusion Models, CC BY 4.0)
- A bakery production line (page 7) (Generated With Diffusion Models, CC BY 4.0)
- The gate diagram, the port and index charts and the market tables, drawn in code (Ignacio Ferro, CC BY 4.0)
做法
#1 · 一个调色板里的两种纸
const palette = {
ink: '#16181b', // text and heavy rules
paper: '#f6f4ef', // the page: grey-white newsprint (salmon in Business)
accent: '#b3261e', // news red: flags, kickers, chart marks (petrol in Business)
tint: '#e8e4da', // box fills (a deeper salmon in Business)
rule: '#9d9a93', // hairlines
muted: '#5c5954', // bylines, the folio line, credits
salmon: '#f2d3c0', // the business stock, and the teaser patches on page 1
petrol: '#0f4c5c', // the business accent
};
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: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
配置里的每一种颜色都链接到调色板的八个条目之一。新闻版用paper(#f6f4ef)作页面颜色,用accent(#b3261e)作版名标签、眉题和图表标记。财经版保留这些链接,只改它们的值:分区调色板把paper改成橙红色,accent改成石油蓝(#0f4c5c),tint改成更深的橙红色。salmon另有一个条目,用于头版的报耳和导读条,它们在白色版面上仍然是橙红色。
#2 · 一个标题样式让一页变成财经版
代码见上面的简短回答。# Markets {style="business"}开始一个分区,分区内各页采用样式的palette、layout和bodyStyle:六栏,栏间距4 mm(每栏45.2 mm,新闻版为54.6 mm),正文8.8 pt,行距仍是11.4 pt。页面颜色也跟着调色板走。page.backgroundColor链接到paper,分区调色板一旦给paper另一个值,这个分区的每一页都用它来画:标题所开的那一页,以及稿件转到的任何一页。所以财经版从边到边都是橙红色,而栏间线沿用文档的设置(样式的layout没有改它),像在五栏之间一样画在六栏之间。
#3 · 每一版都以版名标签开头
const flagParts = [
depth(3),
rule('bar', 3, at('#depth', 'align-bottom', 0, -1.4)),
text('flag', '{titleText}', { ...caps(12, 700, 'paper'), box: patch('accent', pad(1.3, 3.5)) },
at('#bar', 'above')),
];
const FOLIO = 9; // mm from the top edge
const folioLine = (parity, side, s) => [ // s: +1 on a verso (folio on the left), −1 on a recto
text(`n-${parity}`, '{pageNumber}', { ...sans(11, 700), align: side },
at('page', `top-${side}`, s * M.side, FOLIO)),
text(`t-${parity}`, '{title} · {publishDate}', { ...caps(7.5, 600, 'muted'), align: side },
at(`#n-${parity}`, s > 0 ? 'right-of' : 'left-of', s * 3, 1)),
text(`c-${parity}`, '{chapterTitle}', { ...caps(7.5, 700, 'accent'),
align: s > 0 ? 'right' : 'left' }, at('page', `top-${s > 0 ? 'right' : 'left'}`,
-s * M.side, FOLIO + 1)),
].map((element) => ({ ...element, parity }));
const header = { elements: [...folioLine('even', 'left', 1), ...folioLine('odd', 'right', -1),
{ kind: 'rule', id: 'folio-rule', thickness: pt(0.5), color: col('ink'), placement: {
...at('page', 'top-left', M.side, FOLIO + 5), size: { width: mm(WIDE) } } }] };
H1是通页宽的版头,breakBefore的奇偶为'any',所以每个标题都从下一页开始,不论单双页。它的设计是3 pt粗线上的一个标签,深三行网格。页眉行固定在离上边缘9 mm处:外侧是页码、报名和日期,内侧是用强调色排的{chapterTitle},在橙红色版面上调色板把它变成石油蓝。
#4 · 跨k栏的照片和图表
const unnumbered = (id, name, captionStyle) => ({ id, name, shortLabel: name, captionPrefix: '',
numberingTemplate: '', resetOn: 'never', counterFormat: 'decimal', captionStyle });
const resourceTypes = [unnumbered('picture', 'Picture'),
unnumbered('panel', 'Panel', { position: 'above', fontSize: pt(9.5) })];
const res = (id, typeId, kind, body, extra) => ({ id, typeId, kind, [kind]: body,
createdAt: 0, updatedAt: 0, ...extra });
const photo = (id, file, [w, h], placement, resolution) => res(id, 'picture', 'bitmap',
{ fileId: file, format: 'jpeg', width: w, height: h, ...(resolution && { resolution }) },
{ placement, ...CAPTIONS[id] });
const drawing = (id, [w, h], placement) => res(id, 'picture', 'svg',
{ fileId: `${id}.svg`, width: w, height: h }, { placement, ...CAPTIONS[id] });
const data = (id, model, caption, note) => res(id, 'panel', 'table', { model },
{ placement: here, caption, note });
const top = (columns) => ({ position: 'top', columns }); // a float across k columns
const here = { position: 'here' }; // in the flow: in a column, or across a box
const resources = [
photo('barrier', 'barrier-1800.jpg', [1800, 1106], here), // in the banner box: page-wide
photo('welders', 'apprentices-1536.jpg', [1536, 1024], top(3)),
drawing('gate', [1130, 500], top(3)),
photo('ferry', 'ferry-1536.jpg', [1536, 1024], top(4)),
photo('cartoon', 'cartoon-1280.jpg', [1280, 853], top(4), 140),
photo('cranes', 'cranes-1800.jpg', [1800, 750], here),
drawing('throughput', [1130, 700], top(2)),
drawing('mx40', [2910, 1000], here), drawing('sectors', [2910, 880], here),
photo('loaves', 'bakery-1536.jpg', [1536, 1024], top(3)),
// The tables sit where the text names them: no float.
...Object.entries(TABLES).map(([id, [model, caption, note]]) => data(id, model, caption, note)),
...SECTORS.map((_, i) => res(`prices-${i + 1}`, 'panel', 'table',
{ styleId: 'prices', model: pricesTable(i, 21) }, { placement: here })),
];
top(3)就是placement: { position: 'top', columns: 3 }:船厂照片占新闻版五栏中的三栏,渡轮占四栏,面包厂占财经版六栏中的三栏,港口图表占两栏。从第1栏的段落引用的浮动体,会占据其后仍然空着的各栏的顶部,所以这些图从第2栏开始,报道在旁边往下排。这样的图片只有在本页下方不再排别的报道时才会留在自己的报道里:之后再排一篇通栏报道,可能把图片带进那篇报道的区域,或推到下一页。所以第2页和第3页以浮动到页脚的广告收尾,而不是再排一篇报道。横贯整版的照片以行内方式(here)放在标题框里。表格也在正文流中,放在页脚的通页宽框里。
#5 · 标题、数字框、数据和广告都是框
const none = pad(0, 0);
const banner = { id: 'banner', backgroundEnabled: false, padding: none,
titleStyle: { ...caps(8.5, 700, 'accent'), gap: mm(1.2) }, // the kicker
marginTop: pt(0), marginBottom: pt(LEAD / 2),
body: { fontFamily: 'Source Serif 4', fontSize: pt(13), lineHeight: pt(16.5), textAlign: 'left',
firstLineIndent: pt(0) } };
const story = { ...banner, id: 'story', marginTop: pt(LEAD), padding: { ...none, top: mm(2.5) },
stripe: { enabled: true, side: 'top', width: pt(1), color: col('ink') } };
const boxBody = { fontFamily: 'Archivo Narrow', fontSize: pt(9.5), lineHeight: pt(LEAD),
textAlign: 'left', firstLineIndent: pt(0), paragraphSpacing: true, boldColor: col('accent') };
const briefs = { id: 'briefs', background: col('tint'), padding: pad(2.8, 3),
titleStyle: { ...caps(9, 700, 'accent'), gap: mm(1.5) }, body: boxBody };
const teaser = { ...briefs, id: 'teaser', background: col('salmon'), columnGap: mm(4.5),
body: { ...boxBody, fontSize: pt(10.5), lineHeight: pt(13.5) } };
const panel = { ...story, id: 'panel', marginTop: pt(0), titleStyle: briefs.titleStyle,
stripe: { ...story.stripe, width: pt(2.5), color: col('accent') },
body: { ...boxBody, fontFamily: 'Source Serif 4' } };
const dataBox = { ...story, id: 'data', marginTop: pt(0), columnGap: mm(4.5) };
const ad = { id: 'ad', backgroundEnabled: false, marginTop: pt(LEAD),
border: { enabled: true, color: col('ink'), width: pt(0.75) },
padding: { ...pad(6, 6), top: mm(3) },
titleStyle: { ...caps(6.5, 600, 'muted'), gap: mm(4) },
body: { ...boxBody, fontSize: pt(14), lineHeight: pt(18), boldColor: col('ink') } };
const pullQuote = { ...story, id: 'quote', columns: 2, marginTop: pt(0),
body: { ...banner.body, fontFamily: 'Playfair Display', fontSize: pt(19), lineHeight: pt(23),
italic: true } }; // a pull quote, floated across two columns
const headline = (id, size, look = {}) => ({ id, fontSize: pt(size), lineHeight: pt(size * 1.04),
marginBottom: pt(size * 0.2), ...look });
通栏标题是一个无边框的通页宽框,里面是三种字号之一的H2,上方1 pt的线标出下一篇报道。第5版的The terminal in numbers框浮动在六栏中的两栏上(围栏上写columns="2"),第4版的引语框则在样式里用columns: 2做到同样的效果。数据框用一组:::columns把两到四张表并排,广告是浮到页脚的通页宽框,外加0.75 pt的边线。
#6 · Folio所用的纸张
新闻版不用设置:folio.paper是45 g/m²的新闻纸,binding: { type: 'folded', cover: 'pages' }把两张对折的纸套在一起,第1版在外,第8版作封底。财经版放在一个块里:
:::paper{type="newsprint" shade="#faede6"}
# Business {style="business-front"}
…
# Share prices {style="business"}
…
:::块里每一页都带有这种色调的page.paper,Folio就用这种纸来印。色调是把页面颜色向白色推60%(README §4):平面页面已经画了#f2d3c0,下面再垫一整张橙红色纸会染两次色。画布、HTML和PDF不读:::paper,画的是页面颜色,所以分区调色板也要改paper。
完整食谱
// ═══ Postext Cookbook · Nº 134 · A business section on salmon newsprint ═══
// https://postext.dev/en/cookbook/business-section-on-salmon
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated (CC BY 4.0)
// Fonts: Source Serif 4, Playfair Display, Archivo Narrow (SIL OFL 1.1) · Needs postext ≥ 1.65.0
//
// Eight pages: four of news in five columns, then Business on salmon paper in six.
// One heading style carries the change; a :::paper run gives Folio the salmon stock.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'business-section-on-salmon';
// ─── 1 · Design ───
// #region palette: newsprint, ink and a news red; the Business section swaps three of them
const palette = {
ink: '#16181b', // text and heavy rules
paper: '#f6f4ef', // the page: grey-white newsprint (salmon in Business)
accent: '#b3261e', // news red: flags, kickers, chart marks (petrol in Business)
tint: '#e8e4da', // box fills (a deeper salmon in Business)
rule: '#9d9a93', // hairlines
muted: '#5c5954', // bylines, the folio line, credits
salmon: '#f2d3c0', // the business stock, and the teaser patches on page 1
petrol: '#0f4c5c', // the business accent
};
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: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion
const PAGE = { width: 315, height: 470 }; // mm: the 'berliner' preset
const M = { top: 19, bottom: 14, side: 12 }; // mm: narrow newspaper margins, not mirrored
const WIDE = PAGE.width - 2 * M.side; // the text block's width
const LEAD = 11.4; // pt: the body leading, the same in both sections so the grid holds
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, align: 'left',
overflow: 'wrap', color: col('ink'), ...look, placement }); // no text ends in an ellipsis
const sans = (size, weight = 400, look = {}) => ({ fontFamily: 'Archivo Narrow',
fontSize: pt(size), fontWeight: weight, ...look });
const caps = (size, weight, colour = 'ink') => sans(size, weight, { color: col(colour),
textTransform: 'uppercase', letterSpacing: pt(size * 0.16) });
const rule = (id, weight, placement) => ({ kind: 'rule', id, thickness: pt(weight),
color: col('ink'), placement: { ...placement, size: { width: 'fill' } } });
const box = (id, style, placement, size) => ({ kind: 'box', id, style, placement: { ...placement,
size } }); // an empty box a whole number of grid lines deep sets an opener's depth:
const depth = (lines) => box('depth', {}, at('container', 'top-left'), { width: 'fill',
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#换纸不换网格
只有palette、没有layout的标题样式会保留文档的五栏和栏间线,照样给分区的每一页画上新颜色:{ id: 'weekend', palette: { paper: '#efe6cf' } }把周末副刊印在米黄色新闻纸上。再把这些页面放进一个:::paper块,色调向白色推60%,Folio就会用相配的纸来印。
#把财经版做成可抽出的夹页
八个版面折成两张纸,一张套一张:第1–2版和第7–8版在外面一张,第3–6版在里面一张。Folio给每一张叶子用它奇数页的纸,所以第7、8版是橙红色的,虽然印刷机会把它们和头版印在同一张纸上。把财经版移到第3–6版,它们就组成里面那张纸,可以用橙红色纸单独印刷,读者也能整张抽出来。
常见问题
易错点
通栏标题总是开启新页
标题级别或样式设了span: 'page'的标题,会作为章首页排在页面顶部,不管它有没有breakBefore。放在其他文字之后,或同一页另一个章首页之后,它都会移到下一页,当前页余下部分留空。报头下横跨两栏(或竖排页面两层)的通栏大标题,要放进章首页自己的设计里,与报头并列;或者放进:::callout{span="page"}框中,作为不设span的标题,newspaper-front-page就是这样排通栏标题的。 设计过的章首页 →
易错点
换纸段从新页开始、在新页结束,一张纸取其右页的纸张
:::paper中的文字从新页开始,其后的文字也从新页开始。一张纸有两页而只有一种纸张,即其右页的纸张,所以从左页开始的换纸段,这一页会印在它所在那张纸的纸张上。需要从右页开始的地方,加一个分页。 为一组页面换用纸张 →
易错点
cover: 'pages'需要偶数页才有封底
binding.cover设为'pages'时,第一页作为封面翻动,最后一页只有落在左页时才作为封底。页数为奇数时书只有封面没有封底:把页数补成偶数,或保留书壳。 纸张、装订、台面与光照(Folio) →
致谢
- 文本
- 原创文字, CC BY 4.0
- 图片
- The tidal barrier in a storm (page 1) · Generated With Diffusion Models · CC BY 4.0
- Apprentices welding in the shipyard (page 2) · Generated With Diffusion Models · CC BY 4.0
- The island ferry leaving Skerra pier (page 3) · Generated With Diffusion Models · CC BY 4.0
- The editorial cartoon (page 4) · Generated With Diffusion Models · CC BY 4.0
- Container cranes at dawn (page 5) · Generated With Diffusion Models · CC BY 4.0
- A bakery production line (page 7) · Generated With Diffusion Models · CC BY 4.0
- The gate diagram, the port and index charts and the market tables, drawn in code · Ignacio Ferro · CC BY 4.0
- 字体
- Source Serif 4 (SIL OFL 1.1) · Playfair Display (SIL OFL 1.1) · Archivo Narrow (SIL OFL 1.1)


