Chapter 3.13 · Part II · The craft
Configuration: exercises
Exercise styles (exerciseStyles) and the book's exercise settings (exercises): number badges, instruction type, option labels and markers, blanks, true/false answers, matching, word banks, writing areas, grids, long division, difficulty marks, icons, the answers' colour, where solutions print, the teacher's edition and the screen editions
In short
This page lists every setting for the look of exercises. An exercise style decides how the number is printed, how the options are labelled, what a blank to fill in looks like, how the lines to write on are ruled and how grids and sums are drawn. The book settings decide where the solutions are printed and whether the book is the pupil's edition or the teacher's. They also decide how readers answer the exercises on screen. The Exercises page explains how to write the exercises themselves.
#Exercise styles
The exerciseStyles property declares the named styles an exercise picks with :::exercise{style="…"}. A style is the form of a family of exercises; the questions and the answers stay in the Markdown (see Exercises). One style, exercise, ships by default, so the fence works with no configuration; declaring exerciseStyles replaces it, and the first style declared is the one an exercise without style takes. Every field is optional, and the defaults follow the document language where schools differ: option labels, true/false letters, the long division layout, the words printed.
const config: PostextConfig = {
exerciseStyles: [
{
id: 'activity',
box: 'activity-frame',
number: { shape: 'disc', background: { hex: '#2a5ea8', model: 'hex' } },
instruction: { fontFamily: 'Source Sans 3' },
options: { marker: 'circle' },
blank: { look: 'dots', width: 'answer' },
area: { kind: 'grid', lines: 4 },
level: { glyph: '★', empty: '☆' },
icons: { pair: { glyph: '👥' } },
},
{ id: 'quiz', extends: 'activity', options: { layout: 'row', columns: 4 } },
],
};| Property | Type | Default | Description |
|---|---|---|---|
id | string | — | Identifier selected by :::exercise{style="…"}. An unknown id falls back to the first style and is reported (exerciseUnknownStyle). |
name | string | id | Human-readable name (editor UI only). |
extends | string | — | The id of a style this one is based on. Each group (number, options, blank…) is merged field by field, icons by id. |
box | string | — | A calloutStyles id for the exercise's frame: background, border, stripe, padding, placement, splitting. Unset, the exercise is set in the running text with no frame and is kept together on one page. |
number | object | — | How the number prints. See Number. |
instruction | object | — | The type of the instruction. See Instruction. |
options | object | — | The options of a choice question. See Options. |
blank | object | — | How a [[…]] prints. See Blanks. |
trueFalse | object | — | The answers of a true/false statement. See True or false. |
match | object | — | Two columns to join. See Match. |
bank | object | — | The word bank. See Word bank. |
area | object | — | Writing areas. See Writing area. |
grid | object | — | The cells of word searches, crosswords and operations. See Grids. |
arithmetic | object | — | Operations in columns. See Arithmetic. |
level | object | — | Difficulty marks. See Difficulty. |
icons | Record<string, ExerciseIcon> | {} | Activity icons by id, named by a fence's icon. See Icons. |
answers | object | — | How answers print in a teacher's edition, in a model item and in the solutions. See Answers. |
solutions | ExerciseSolutionsConfig | — | The book's exercises.solutions for this style's exercises: only the fields set here change. |
digital | object | — | Colours of the screen editions. See Screen colours. |
marginTop | Dimension | 1em | Room above an exercise without a box. |
marginBottom | Dimension | 1em | Room below an exercise without a box. |
itemSpacing | Dimension | 0.25em | Room between two items: options, questions, statements, pairs. |
#Number
number sets the exercise number. A bare number is bold, in the main colour, with a full stop after it; a shaped one is a white figure in a disc, a square or a rounded square of the main colour, with nothing after it.
| Property | Type | Default | Description |
|---|---|---|---|
show | boolean | true | Print the number. The count goes on either way. |
label | boolean | string | false | A word before the number: true takes the document language's word (Exercise, Ejercicio, Exercice, Übung, 练习, 練習, تمرين…), a string is the word itself ('Activity'). |
shape | 'none' | 'disc' | 'square' | 'rounded' | 'none' | The shape the number is set in. |
color | ColorValue | white on a shape, else the main colour | The number's colour. |
background | ColorValue | the main colour | The shape's fill. |
fontFamily | string | the text around it | The number's family. |
fontSize | Dimension | 1em | The number's size, an em being the instruction's. |
fontWeight | number | 700 | 600 or more sets it bold. |
suffix | string | '.', none on a shape | Printed after a bare number and its label: '.', ')', '、'. |
template | string | '{n}' | What the number reads: {n} the exercise's count, {h1} and {h2} the chapter's and the section's numbers ('{h1}.{n}' prints 3.4). |
resetOn | 'never' | 'h1' … 'h6' | 'h1' | The heading level that starts the count again; 'never' counts through the book. |
counter | string | 'exercise' | The counter the style advances. Styles naming one counter share it; a style with a counter of its own ('review') numbers its exercises apart. |
format | ResourceCounterFormat | 'decimal' | The numerals of {n}, as a resource counter has them: 'roman-upper', 'alpha-lower', 'simp-chinese-informal' (一, 二), 'circled-decimal' (①, ②), 'arabic-indic'… |
#Instruction
instruction sets the leading paragraphs of the exercise. Unset fields take the body text's.
| Property | Type | Default | Description |
|---|---|---|---|
bold | boolean | true | Set the instruction in bold. |
italic | boolean | false | Set it in italic. |
color | ColorValue | the text's | Its colour, bold runs included. |
fontFamily | string | the text's | Its family: a sans-serif instruction over a serif text is common in school books. |
fontSize | Dimension | the text's | Its size. |
#Options
options sets the options of a choice question (- [ ] …).
| Property | Type | Default | Description |
|---|---|---|---|
labels | ResourceCounterFormat | 'none' | by language | How the options are counted: 'alpha-lower' (a, b, c), 'alpha-upper' in Chinese (A, B, C), 'katakana' in Japanese (ア, イ, ウ), 'abjad' in Arabic (أ, ب, ج). Also 'decimal', 'katakana-iroha', 'circled-decimal'… 'none' prints no label. |
prefix | string | '' | Before the label: '(' for (a). |
suffix | string | ')'; '.' in Chinese, none in Japanese | After the label. |
marker | 'none' | 'box' | 'circle' | 'none' | A box or a ring before each option, to tick. With 'none' the reader rings the label. |
layout | 'stack' | 'row' | 'stack' | 'stack': one option a line, its turnover lines hung under its text. 'row': the options side by side. A fence's columns=n sets them in rows too. |
columns | number | all of them | Options to a row in the 'row' layout (up to 6). |
shuffle | boolean | false | Print the options in a shuffled order, the same in every output and in the key. |
indent | Dimension | 1em | The options' indent from the text's edge, for a question without a stem. |
bracket | boolean | false | A bracket ( ) at the end of each question's stem to write the letter in, as Chinese and Japanese tests print it. A teacher's edition writes the letter in it. |
#Blanks
blank sets how a [[…]] prints in the pupil's text: room the size of the answer with a line, dots or a box, the answer itself not painted.
| Property | Type | Default | Description |
|---|---|---|---|
look | 'line' | 'dots' | 'box' | 'none' | 'line' | A line to write on, a dotted line, a box, or empty room. |
width | 'answer' | 'longest' | Dimension | 'longest' | 'longest': every blank of the exercise as wide as its longest answer, so no blank gives its answer away. 'answer': each as wide as its own answer. A length: that width for all. A gap's {width=N} wins over it. |
extra | Dimension | 1.5em | Room added to the answer's width, in whole ems. |
minWidth | Dimension | 3em | The narrowest blank. |
color | ColorValue | black | The colour of the line, the dots or the box. Set, it also colours the boxes and rings to tick and the frames of the bank's words, which are otherwise in the main colour. |
weight | Dimension | 0.6pt | The line's weight. |
#True or false
trueFalse sets the answers at the end of a statement.
| Property | Type | Default | Description |
|---|---|---|---|
labels | [string, string] | by language | The two answers: ['T', 'F'] in English; V F in Spanish, Catalan, French, Italian and Portuguese; R F in German; √ × in Chinese; ○ × in Japanese; صح خطأ in Arabic. |
look | 'boxes' | 'bracket' | 'boxes' | 'boxes': each label with a box to tick, at the end of the line. 'bracket': one blank to write the answer in. |
#Match
match sets an exercise of pairs.
| Property | Type | Default | Description |
|---|---|---|---|
look | 'dots' | 'letters' | 'dots' | 'dots': two columns with a dot by each item, to join with a line. 'letters': the right column lettered, a blank by each left item for the letter. |
gap | Dimension | 4em | Room between the two columns. |
dotSize | Dimension | 0.35em | The dots' diameter. |
color | ColorValue | the main colour | The dots, and the word bank's frame. |
#Word bank
bank sets the box of words of a gaps exercise with bank or ::bank[…], and of every sort exercise. The box stands where a ::bank line is written, else under the instruction.
| Property | Type | Default | Description |
|---|---|---|---|
box | string | a frame in the match colour | A calloutStyles id for the bank's box. |
order | 'shuffle' | 'alpha' | 'written' | 'shuffle' | The words shuffled (seeded), in alphabetical order in the document language, or as written. |
separator | string | an em space | Between two words. Each word is set in a chip with a thin frame. |
#Writing area
area sets the space under an open question, under a scrambled sentence and in the columns of a sort exercise.
| Property | Type | Default | Description |
|---|---|---|---|
kind | 'lines' | 'dots' | 'grid' | 'seyes' | 'tianzige' | 'box' | 'none' | 'lines' | Ruled lines, a row of dots, squared paper, French Seyès ruling, 田字格 squares, an empty frame, or blank room. A fence's area overrides it. |
lines | number | 3 | How many lines tall. A fence's lines overrides it. |
spacing | Dimension | 1.35 times the text's line height (1.2 for grids) | The distance between two lines. |
color | ColorValue | a light grey | The ruling's colour. |
weight | Dimension | 0.5pt | The ruling's weight. |
#Grids
grid sets the cells of word searches, crosswords and operations in columns.
| Property | Type | Default | Description |
|---|---|---|---|
cell | Dimension | 1.6em | A cell's side. |
fontFamily | string | the text's | The letters' and digits' family. |
fontSize | Dimension | 0.58 of the cell's side | The size of the letters and digits, an em being the text's. |
color | ColorValue | the text's | The letters' and digits' colour. |
rule | ColorValue | a mid grey | The cells' rules. |
ruleWidth | Dimension | 0.6pt | Their weight. |
blocked | ColorValue | — | The fill of the crossword's cells that no word takes. Unset, the grid prints only the cells of its words. |
uppercase | boolean | true | Set the letters of word searches and crosswords in capitals, in the document language's case rules. |
#Arithmetic
arithmetic sets operations in columns.
| Property | Type | Default | Description |
|---|---|---|---|
division | 'bracket' | 'potence' | 'inline' | by language | Long division. 'bracket': the divisor left of the dividend, a bracket over it, the quotient on top (English, Chinese, Japanese, Arabic, and any language without its own). 'potence': the divisor right of the dividend under an L, the quotient under the divisor (Spanish, Catalan, French, Italian, Portuguese). 'inline': 864 : 4 = with the quotient on the line and the steps under it (German). |
columns | number | 4 | Operations to a row, fewer when the column is too narrow. |
#Difficulty
level sets the marks a fence's level prints after the number, in a smaller size.
| Property | Type | Default | Description |
|---|---|---|---|
glyph | string | '●' | A level reached: '★', '■'. |
empty | string | '○' | A level not reached; '' prints none. |
max | number | 3 | The highest level: level=2 with max: 3 prints ●●○. |
color | ColorValue | the main colour | The marks' colour. |
#Icons
icons maps an id to an activity icon (oral, written, pair work, listening, calculator), printed after the number when a fence names it: icon="pair".
| Property | Type | Default | Description |
|---|---|---|---|
glyph | string | — | A character to print: '✎', '🎧', a glyph of an icon font. |
fontFamily | string | — | The family of an icon font. |
color | ColorValue | — | The icon's colour. |
resourceId | string | — | A bitmap or SVG resource printed as the icon, in place of a glyph. |
alt | string | — | What the icon stands for, for screen readers and the tagged PDF. |
size | number | 0.75 | The icon's height in ems of the instruction: the height of a capital by default. |
An icon prints as an inline symbol after the number: the picture of resourceId when it names one, else the glyph set in fontFamily, in color (the text's when unset). It stands on the instruction's baseline, size ems tall, and its alt is read in its place.
#Answers
answers sets the answers wherever they show: a teacher's edition, the model item of an example exercise, rings and filled boxes, lines drawn between pairs, letters and digits in grids.
| Property | Type | Default | Description |
|---|---|---|---|
color | ColorValue | #d6246e, a magenta red | The answers' colour, as a teacher's book overprints them. |
fontFamily | string | the text's | A face for the answers: a handwriting face is common. |
italic | boolean | false | Set answers in blanks in italic. |
#Screen colours
digital sets how the HTML viewer and EPUB books show a checked answer.
| Property | Type | Default | Description |
|---|---|---|---|
correctColor | ColorValue | a green (#1e8e3e) | A right answer. |
wrongColor | ColorValue | a red (#c5221f) | A wrong answer. |
#Book settings
The exercises property holds the settings of the whole book: the edition, where solutions print, the seed of every shuffle and the screen editions. A book that sets neither exercises nor exerciseStyles lays out and hashes as before.
const config: PostextConfig = {
exercises: {
edition: 'student',
solutions: { placement: 'chapterEnd', layout: 'key' },
seed: 3,
digital: { check: 'instant' },
},
};| Property | Type | Default | Description |
|---|---|---|---|
edition | 'student' | 'teacher' | 'student' | 'teacher' prints every answer in its slot in the answers colour: a teacher's book from the pupil's text. |
solutions | ExerciseSolutionsConfig | — | Where and how the solutions print. See Solutions. |
seed | number | 1 | What every shuffle is drawn from: options, right columns, order items, scrambled words, banks, word-search fillers. Change it for another version of a test; print, screen and key stay in agreement. |
digital | object | — | The HTML viewer and EPUB books. See Screen editions. |
#Solutions
exercises.solutions, and a style's solutions over it for that style's exercises.
| Property | Type | Default | Description |
|---|---|---|---|
placement | 'none' | 'after' | 'inverted' | 'chapterEnd' | 'directive' | 'none' | 'none': no solutions in print. 'after': after each exercise, in smaller type. 'inverted': after each exercise, turned upside down. 'chapterEnd': at the end of the chapter, under heading. 'directive': where a :::solutions line stands. |
box | string | a frameless box in smaller type | A calloutStyles id for a solution's box, and for the list of a chapter's solutions. |
heading | string | the document language's word | The heading of the solutions at the end of a chapter: Solutions, Soluciones, Solucions, Corrigés, Lösungen, Soluzioni, Gabarito, 参考答案, 解答, الحلول. A :::solutions{title="…"} line sets its own. |
layout | 'key' | 'full' | 'full' | 'key': the answers alone (1 b · 2 water). 'full': the key, then the exercise's :::solution. |
#Screen editions
exercises.digital sets how exercises behave in the HTML viewer and in EPUB books.
| Property | Type | Default | Description |
|---|---|---|---|
interactive | boolean | true | Exercises the reader can answer. false shows them as printed. |
persist | boolean | true | Keep the reader's answers in the browser, per book. |
check | 'button' | 'instant' | 'button' | 'button': answers are checked when the reader asks. 'instant': each answer is checked as it is given. |
The screen can have its own exercise settings: htmlViewer.overrides takes exercises and exerciseStyles too, merged over the book's before the HTML viewer lays out, so print keeps its solutions at the end of the chapter while the screen hides them, or the screen drops the writing areas a reader has no use for.
const config: PostextConfig = {
htmlViewer: {
overrides: {
exercises: { solutions: { placement: 'none' } },
exerciseStyles: [{ id: 'exercise', area: { kind: 'none' }, blank: { minWidth: { value: 6, unit: 'em' } } }],
},
},
};