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

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

こたえを逆さまに刷った小学生ドリル

ドリルのシリーズから2ページ。算数は横組み、国語は縦組みで、どの問題の下にもこたえを逆さまに刷ります。

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

1ページ(全4ページ)

  • 仕上がり182 × 257 mm
  • 1段
  • Klee One 12/22
  • Zen Maru Gothic
  • 4ページ
  • レベル
  • Postext 1.59.0
  • 組版時間105 ms
  • コード137行

かんたんな説明

小学生向けのドリルです。1ページは計算、□、記号でえらぶ問題、○×、もう1ページは漢字と読みを縦に組みます。問題ごとにこたえが逆さまに刷ってあり、子どもは本を回して答え合わせをします。

できあがり

B5判、3年生向けドリルのシリーズから2ページを組みます。算数のページは横組みです。水色の帯に教科のラベル、題、マスコットのたぬき。その下に名前の線と点数の枠があり、答えの位ごとに□を置いたひっ算、6つの計算のあとの□、横に並んだア イ ウの選択肢、行末に( )がある○×の問題、式を書く線がついた文章題2問と続きます。漢字のページは国語のドリルの刷り方どおり、上から下へ、右から左へ縦組みにします。読みを見て□に漢字を書く問題、線を引いたことばの読みを( )に書く問題、正しいほうを○でかこむ問題、意味をえらぶ問題です。どの問題の下にも、こたえを灰色の小さな字で逆さまに刷ります。子どもにはこたえの場所が見えますが、ちらっと見ただけでは読めません。答え合わせのときに本を回します。

このレシピが答える質問

  • 答えを問題の下に逆さまに印刷するには?
  • 横組みと同じデザインで、縦組みのドリルのページを組むには?
  • わり算の筆算を国ごとの学校の書き方で組むには?

手短な答え

script.js · 35〜55行コード全体で見る
// `placement: 'inverted'` sets each exercise's key right after it in a box turned 180°: the
// pupil sees where the answers are without reading them, and turns the book to check. The
// key's words come from the exercise (the options' katakana, ○ and ×, the operations), so
// the Markdown holds nothing twice.
const drill = {
  id: 'drill',
  number: { shape: 'square', fontFamily: TEXT, fontWeight: 600, background: col('blue') },
  instruction: { fontFamily: ROUND, bold: false },
  options: { layout: 'row' }, // ア イ ウ side by side (the default labels in Japanese)
  trueFalse: { look: 'bracket' }, // ( ) for ○ or ×
  blank: { look: 'box', width: 'answer', color: col('rule') }, // □ to write in
  area: { kind: 'lines', color: col('rule') },
  grid: { rule: col('rule') },
  solutions: { placement: 'inverted', box: 'kotae' },
  marginTop: em(1.1), marginBottom: em(0.4),
};
const kotae = { id: 'kotae', title: '', backgroundEnabled: false, border: { enabled: false },
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  body: { fontFamily: ROUND, fontSize: pt(8), lineHeight: pt(12), color: col('muted'),
    firstLineIndent: pt(0) },
  marginTop: mm(1), marginBottom: mm(2), keepTogether: true };

材料

種類
Klee One, Zen Maru Gothic (SIL OFL 1.1)
素材
  • kitsune-600.jpg
  • tanuki-600.jpg
  • A young tanuki in a yellow school hat holding a big pencil. (Generated With Diffusion Models, オリジナル)
  • A fox cub in a red scarf reading a book. (Generated With Diffusion Models, オリジナル)

作り方

#1 · 問題ごとのこたえを逆さまにする

コードは上の手短な答えにあります。placement: 'inverted' は、各問題のすぐあとに、こたえを180°回した囲みで置きます。この囲みは問題自身の囲みの中に入るので、改ページで問題とこたえが離れることはありません。こたえは問題から作ります。計算とその答え、正しい選択肢のカタカナ、○と×、穴うめのことばです。こたえの囲みスタイル kotae は、字を小さく灰色にするだけです。

#2 · 横組みにも縦組みにも使える帯

script.js · 59〜76行コード全体で見る
// A heading design on a vertical page is laid along its column: x runs down the page and y
// to the left, so the same band stands at the right edge, from head to foot.
const BAND = 30; // mm: the band's depth (its height across, its width down)
const header = { enabled: true, minHeight: mm(BAND + 3), slot: { elements: [
  { kind: 'box', id: 'band', reserve: false, style: { backgroundColor: col('tint'),
    borderRadius: mm(4) }, placement: { anchor: { to: 'container', edge: 'top-left' },
    size: { width: 'fill', height: mm(BAND) } } },
  { kind: 'image', id: 'mascot', resourceId: '{attr.pic}', decorative: true, reserve: false,
    placement: { anchor: { to: 'container', edge: 'top-right' }, offset: { x: mm(-4), y: mm(1) },
      size: { width: mm(28), height: mm(28) } } },
  { kind: 'text', id: 'subject', content: '{attr.kicker}', fontFamily: ROUND, fontSize: pt(10),
    fontWeight: 700, color: col('ink'), box: { backgroundColor: col('sun'), borderRadius: mm(3),
      padding: { top: mm(0.6), bottom: mm(0.6), left: mm(2.4), right: mm(2.4) } },
    placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { x: mm(5), y: mm(5) } } },
  { kind: 'text', id: 'title', content: '{titleText}', fontFamily: ROUND, fontSize: pt(20),
    fontWeight: 700, color: col('ink'),
    placement: { anchor: { to: '#subject', edge: 'below' }, offset: { x: mm(0), y: mm(2.5) } } },
] } };

縦組みのページでは、見出しのデザインは行に沿って置かれます。xはページの下へ、yは左へ進みます。top-left に固定して全幅にした帯は、算数のページでは上端に、漢字のページでは右端に立ちます。top-right に固定したマスコットは、どちらのページでも帯の終わりに来ます。デザインのどこにも、向きは書いてありません。

#3 · ひとつの原稿から2冊のドリル

script.js · 271〜279行コード全体で見る
// Two drill books of one series: arithmetic across, bound on the left; kanji in columns,
// bound on the right (vertical text binds there by itself).
const [sansu, kokugo] = markdown.split(/(?=^# 春のことば)/m);
const build = (text) => withLoadedFonts(() => buildDocument({ markdown: text, resources },
  config()), { ...kitFonts(FONTS), text: markdown });
const across = await build(sansu);
// 国語 is set in columns, top to bottom, right to left: the same design, turned.
writingMode = 'vertical-rl';
const docs = [across, await build(kokugo)];

設定は関数なので、組むたびに別のオブジェクトができます。2冊の違いは writingMode だけです。縦組みにすると、国語のドリルはそれだけで右綴じになります。showBook は2冊を背の左右に分けて並べます。本文は教科書体の Klee One、ラベルは Zen Maru Gothic です。どちらも縦組み用の約物を読み込み、漢字のページのかっこに使います。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 172 · A Japanese drill with the answers upside down ═══
// https://postext.dev/en/cookbook/japanese-drill-upside-down-answers
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Klee One, Zen Maru Gothic (SIL OFL 1.1) · Needs postext ≥ 1.59.0
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
  loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'ja'; // @lang: the language of the frame; the drill is Japanese in all
const RECIPE = 'japanese-drill-upside-down-answers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a drill book's blue, a warm yellow and a pale sky for the band
const palette = {
  ink: '#23272c', // text
  blue: '#2a6cb0', // the accent: exercise numbers, the title band's rule, the score box
  sun: '#f2c14e', // the subject badge
  tint: '#eaf2fb', // the title band
  rule: '#a8bfd8', // writing lines and boxes
  muted: '#69717b', // folios, the name line, the upside-down answers
  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.blue, model: 'hex' } },
];
// #endregion
// 教科書体 for the text a child copies from, a round gothic for the labels.
const [TEXT, ROUND] = ['Klee One', 'Zen Maru Gothic'];

// #region answer: the answers printed upside down under each exercise
// `placement: 'inverted'` sets each exercise's key right after it in a box turned 180°: the
// pupil sees where the answers are without reading them, and turns the book to check. The
// key's words come from the exercise (the options' katakana, ○ and ×, the operations), so
// the Markdown holds nothing twice.
const drill = {
  id: 'drill',
  number: { shape: 'square', fontFamily: TEXT, fontWeight: 600, background: col('blue') },
  instruction: { fontFamily: ROUND, bold: false },
  options: { layout: 'row' }, // ア イ ウ side by side (the default labels in Japanese)
  trueFalse: { look: 'bracket' }, // ( ) for ○ or ×
  blank: { look: 'box', width: 'answer', color: col('rule') }, // □ to write in
  area: { kind: 'lines', color: col('rule') },
  grid: { rule: col('rule') },
  solutions: { placement: 'inverted', box: 'kotae' },

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

アレンジ

#こたえを最後にまとめる

別冊解答がつくドリルなら、こたえは問題のページに入れません。chapterEnd にすると、最後の問題のあとにまとめて載ります。

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

#パズルのページを組む

パズルのページも、同じやり方でこたえを逆さまにして、2段のカードに載せています。

よくあるつまずき

つまずき

中国語の書体はcjkブロックを通じてスライス単位で読み込む

Fontsourceは中国語、日本語、韓国語のファミリーを、ウェイトごとに約100個のファイルとして配信し、各ファイルが文字の範囲を受け持ちます。loadFontsが取得するのはlatinファイルだけなので、画面では漢字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、漢字が空の四角で印字されます。キットのcjkブロックを挙げ、loadFontsのあとにloadCjkFonts(FONTS, markdown)を呼び(本で複数のCJK書体を使うときは、それぞれの書体で組むテキストを渡して書体ごとに1回)、renderToPdfにfontProvider: cjkPdfProviderを渡してください。どちらもテキストの文字を含むファイルを取得します。 中国語・日本語・韓国語のフォント →

つまずき

日本語のテキストのタグは'ja'。zh-HansやLANGにしない

レシピの版はenとesですが、日本語のサンプルはどちらの版でも日本語です。`locale: LANG`では英語やスペイン語とタグ付けされ、中国語のタグでは中国語の規則で組まれます(開明式の約物、小書きの仮名が行頭に来てもよい、図の代わりに图、PDFでは中国の字形)。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、'ja'以外のタグでは日本語の字形ではなく別の字形(中国語のタグでは中国の字形)になり、改行の位置も変わります。'ja'と書いてください。日本の地域(JLReqの改行と約物、ゴマの圏点、ルビの間隔、図と表の表示名)が選ばれ、ハイフネーションが切られます。リントは、zhやkoのタグで仮名を含むテキストをエラーにします。 日本語の改行(禁則処理) →

  • 今のところ、空欄の上に読みがなは置けません。[[…]] の中のルビは、隠したこたえの一部になります。漢字の書き取りの問題では、読みを1行に置いてそのあとに□を続け、:::columns のグループで1列に3つずつ並べます。縦組みのページでは、ふりがなと同じように、読みが□の横に立ちます。
  • Klee One には400と600しかありません。boldFontWeight: 600 にしておくと、小問と大問の番号も含めて、太字はすべて実在するウェイトで組まれます。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
画像
  • A young tanuki in a yellow school hat holding a big pencil. · Generated With Diffusion Models · オリジナル
  • A fox cub in a red scarf reading a book. · Generated With Diffusion Models · オリジナル
フォント
Klee One (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1)
Sandbox