本文へスキップ
レシピ番号174

レシピ集 · 第12章 · 教科書

答えを逆さに刷ったパズルページ

子ども向け雑誌のパズルページです。クロスワード、ワードサーチ、なぞなぞ、話の並べ替えなどをカードに載せ、答えはそれぞれ逆さに刷ります。

このページの内容
出力
Canvas · PDF
レベル
中級
Postext
Postext 1.59.0で検証済み
1.59.0以上が必要 · postext-pdf ≥ 1.59.0
ライセンス
2026年10月24日更新
コードMIT · 本文CC BY 4.0

1ページ(全2ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり210 × 280 mm
  • 2段, 段間7 mm
  • Nunito 10.5/15
  • Baloo 2
  • Fredoka
  • 2ページ
  • レベル
  • Postext 1.59.0
  • 組版時間71 ms
  • コード129行

かんたんな説明

海がテーマの子ども向け雑誌のパズルページです。パズルは1つずつカードに載り、答えはその下に逆さに刷ってあるので、読者は雑誌を回して答え合わせをします。

できあがり

海をテーマにした子ども向け雑誌『Splash!』のパズルページです。A4判の2ページで、2段組みです。1ページ目の上部をサンゴ礁の絵が埋め、タイトルはひらけた海面の上に置きます。その下で、パズルは1つずつ、サンゴ色の番号が付いたクリーム色のカードに載ります。6種類の海の生き物とそのカギで作るクロスワード、8つの単語をヨコ、タテ、ななめ、逆向きに隠したワードサーチ、3つの選択肢から丸で囲むなぞなぞ、ウミガメの一生を順番に並べる問題、語順がばらばらの豆知識、海の動物の赤ちゃんを名前と結ぶ問題です。どのパズルも、カードの中の問題の下に、小さな灰色の文字で答えを逆さに刷ります。パズル雑誌が昔から使ってきた答えの隠し方です。

このレシピが答える質問

  • 語のリストから単語探しやクロスワードを作るには?
  • 答えを問題の下に逆さまに印刷するには?

手短な答え

script.js · 33〜59行コード全体で見る
// placement 'inverted' sets each puzzle's key after it in a box turned 180°, inside the
// puzzle's card, so a page break never parts a puzzle from its answers. The key is made
// from the puzzle: the crossword's words by number, the ringed option, the right order.
const puzzle = {
  id: 'puzzle',
  box: 'card', // the card each puzzle sits on (a calloutStyles id)
  number: { shape: 'disc', fontFamily: DISPLAY, background: col('coral') },
  instruction: { fontFamily: TEXT, bold: false },
  options: { marker: 'circle', labels: 'none' }, // a ring to colour in, no letters
  grid: { fontFamily: LABEL, rule: col('sea'), cell: em(1.45) },
  match: { color: col('sea') },
  area: { kind: 'lines', color: col('sea') },
  answers: { color: col('coral'), fontFamily: LABEL },
  solutions: { placement: 'inverted', box: 'turned' },
  marginTop: mm(0), marginBottom: mm(0),
};
const card = { id: 'card', title: '', background: col('card'), borderRadius: mm(4),
  padding: { top: mm(3.5), right: mm(4), bottom: mm(3), left: mm(4) },
  titleStyle: { fontFamily: DISPLAY, fontSize: pt(15), fontWeight: 700, color: col('ink') },
  body: { fontFamily: TEXT, fontSize: pt(10.5), lineHeight: pt(15), color: col('ink'),
    firstLineIndent: pt(0) },
  marginTop: mm(0), marginBottom: mm(5), keepTogether: true };
const turned = { id: 'turned', title: '', backgroundEnabled: false, border: { enabled: false },
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  body: { fontFamily: LABEL, fontSize: pt(8.5), lineHeight: pt(11), color: col('muted'),
    firstLineIndent: pt(0) },
  marginTop: mm(2), marginBottom: mm(0) };

材料

種類
Baloo 2, Nunito, Fredoka (SIL OFL 1.1)
素材
  • hatchling-600.jpg
  • reef-1600x792.jpg
  • A coral reef with a smiling sea turtle, an octopus, a clownfish, a pufferfish and a seahorse under sunbeams. (Generated With Diffusion Models, オリジナル)
  • A baby sea turtle hatching from its egg on the sand. (Generated With Diffusion Models, オリジナル)

作り方

#1 · パズルを1つずつカードに載せ、答えを回す

コードは上の手短な答えにあります。練習問題スタイルのboxは囲みスタイルを指定するので、どのパズルもカードの上に組まれ、番号は円の中に、タイトルは問題文の1行目になります。placement: 'inverted'は、各パズルのあとに答えを180°回転した囲みに入れてカードの中に置くので、問題と答えが別のページに分かれることはありません。マス目と書き込み線はカードの内側の余白に収まります。

#2 · マス目はエンジンに作らせる

Markdownに書くのは単語だけです。クロスワードは- OCTOPUS: Eight arms and three hearts、ワードサーチは- SHELLです。エンジンはどの単語もほかの単語と交わるようにクロスワードを組み、読む順に単語の頭に番号を振ります。ワードサーチの単語はブロックが指定する方向(directions="across down diagonal backwards")に隠し、残りのマスは同じ単語の文字で埋めます。どちらもシード値が固定なので、マス目は何度組んでもどの出力でも同じです。スペイン語版は自分の単語で自分のマス目を作ります。

#3 · 2段にまたがるサンゴ礁

script.js · 63〜82行コード全体で見る
const BAND = 104; // mm from the top edge: the painting's height at the page's width
const opener = { enabled: true, minHeight: mm(BAND - 16 + 6), slot: { elements: [
  { kind: 'image', id: 'reef', resourceId: 'reef', decorative: true, reserve: false,
    placement: { anchor: { to: 'page', edge: 'top-left' },
      size: { width: mm(210), height: mm(BAND) } } },
  { kind: 'text', id: 'kicker', content: '{attr.kicker}', fontFamily: LABEL, fontSize: pt(11),
    fontWeight: 600, color: col('paper'), textTransform: 'uppercase', letterSpacing: pt(2),
    box: { backgroundColor: col('coral'), borderRadius: mm(2),
      padding: { top: mm(0.8), bottom: mm(0.8), left: mm(2.4), right: mm(2.2) } },
    placement: { anchor: { to: 'page', edge: 'top-left' }, offset: { x: mm(16), y: mm(14) } } },
  { kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY, fontSize: pt(56),
    fontWeight: 800, lineHeight: 1, color: col('paper'),
    placement: { anchor: { to: '#kicker', edge: 'below' }, offset: { x: mm(0), y: mm(3) } } },
  { kind: 'text', id: 'sub', content: '{attr.sub}', fontFamily: TEXT, fontSize: pt(12),
    fontWeight: 700, color: col('paper'), overflow: 'wrap', align: 'left',
    box: { backgroundColor: col('ink'), borderRadius: mm(2),
      padding: { top: mm(1.5), bottom: mm(1.5), left: mm(3), right: mm(3) } },
    placement: { anchor: { to: '#title', edge: 'below' }, offset: { x: mm(0), y: mm(2) },
      size: { width: mm(110) } } },
] } };

冒頭の帯は2段にまたがる(span: 'page')ので、どの段でもパズルは絵の下から始まります。画像は帯の比率に合わせて切り抜き、ページに固定しているので、上と左右が裁ち落としになります。リード文は暗い色の囲みに入れ、海の上でも読めるようにします。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 174 · A puzzle page with the answers upside down ═══════
// https://postext.dev/en/cookbook/puzzle-page-upside-down-answers
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Baloo 2, Nunito, Fredoka (SIL OFL 1.1) · Needs postext ≥ 1.59.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'puzzle-page-upside-down-answers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: reef colours: deep blue ink, coral, sea green, a sandy paper
const palette = {
  ink: '#16324a', // text: a deep sea blue
  coral: '#e8573f', // the accent: puzzle numbers, the title kicker
  sea: '#0f8b8d', // the second: crossword and word-search rules, the riddle's rings
  sun: '#ffc93c', // the turtle card's badge
  card: '#fff4e0', // the puzzle cards
  muted: '#5d7180', // answers, colophon, folio
  paper: '#ffffff',
};
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.coral, model: 'hex' } },
];
// #endregion
const [DISPLAY, TEXT, LABEL] = ['Baloo 2', 'Nunito', 'Fredoka'];

// #region answer: every puzzle on a card, its answers turned upside down under it
// placement 'inverted' sets each puzzle's key after it in a box turned 180°, inside the
// puzzle's card, so a page break never parts a puzzle from its answers. The key is made
// from the puzzle: the crossword's words by number, the ringed option, the right order.
const puzzle = {
  id: 'puzzle',
  box: 'card', // the card each puzzle sits on (a calloutStyles id)
  number: { shape: 'disc', fontFamily: DISPLAY, background: col('coral') },
  instruction: { fontFamily: TEXT, bold: false },
  options: { marker: 'circle', labels: 'none' }, // a ring to colour in, no letters
  grid: { fontFamily: LABEL, rule: col('sea'), cell: em(1.45) },
  match: { color: col('sea') },
  area: { kind: 'lines', color: col('sea') },
  answers: { color: col('coral'), fontFamily: LABEL },
  solutions: { placement: 'inverted', box: 'turned' },
  marginTop: mm(0), marginBottom: mm(0),
};

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#単語リストを隠す

難しくしたワードサーチではマス目だけを刷ります。ブロックにhiddenを加えます。

-:::exercise{type=wordsearch size=9 directions="across down diagonal backwards"}
+:::exercise{type=wordsearch size=9 directions="across down diagonal backwards" hidden}

#答えを雑誌の最後に刷る

chapterEndは答えを1つずつ回さず、すべて最後にまとめます。

-  solutions: { placement: 'inverted', box: 'turned' },
+  solutions: { placement: 'chapterEnd' },

よくあるつまずき

  • ほかのどの単語とも交わらないクロスワードの単語は外され、exerciseWordUnplacedとして報告されます。文字を共有する単語を選ぶか、2つのグループをつなぐ単語を1つ足します。
  • パズルのカードは分割しないので、背の高いクロスワードが入りきらないときは次の段へ移ります。単語が長いスペイン語版で確かめてください。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
画像
  • A coral reef with a smiling sea turtle, an octopus, a clownfish, a pufferfish and a seahorse under sunbeams. · Generated With Diffusion Models · オリジナル
  • A baby sea turtle hatching from its egg on the sand. · Generated With Diffusion Models · オリジナル
フォント
Baloo 2 (SIL OFL 1.1) · Nunito (SIL OFL 1.1) · Fredoka (SIL OFL 1.1)
Sandbox