Skip to content

Configuration

Automathics uses a configuration file for automath. The default configuration is embedded in the package and can be overridden by placing a file in one of the following locations (in increasing priority order):

  • /etc/automathics/automath.yaml (system-wide)
  • ~/.config/automathics/automath.yaml (user-level)

Default automath.yaml

debug: False

locale: fr_FR

fonts:
  mode: embedded       # default font-delivery mode for produced HTML:
                       # embedded (base64 data URI, self-contained), served
                       # (a static URL; needs served_base_url) or local
                       # (referenced by name, must be installed). Overridden
                       # by a font_mode entry in an .atmxs, itself overridden
                       # by the --font-mode CLI option.
  text_name: Ubuntu
  text_path:           # custom text font file (ttf/otf/woff2); empty = bundled
  text_bold_path:      # optional bold variant; empty = browser faux-bold
  math_name: Automathics
  math_path:           # custom math font file; empty = bundled
  code_name: Source Code Pro   # what a formula typed on a keyboard is set in
                       # (code{} — a spreadsheet formula, say)
  code_path:           # custom code font file; empty = bundled
  uploaded_dir:        # where user-uploaded (private) fonts are stored; empty =
                       # a fonts/ folder next to the runtime database
  max_upload_bytes_total: 262144000  # cap on the uploads dir total size (250 MB;
                       # POST /fonts is unauthenticated, so uploads are bounded:
                       # over the cap, least-recently-used fonts are evicted —
                       # clients re-upload on demand. 0/empty = unlimited.
                       # Watch usage with `automath fonts list`.
  served_base_url:     # base URL used by --font-mode served for the @font-face
                       # src. MUST be absolute (e.g.
                       # https://your.host/static/fonts/): produced pages are
                       # often opened from blob:/file:, where a relative URL
                       # would not resolve. The operator hosts the .woff2 files
                       # there (nginx static), each under its name with the
                       # first 8 hex digits of its sha256 before the extension
                       # (Ubuntu-R.f841d7c9.woff2), so a changed font changes
                       # URL. Trailing slash included; empty disables serving
                       # (a warning is printed if used anyway).
  size: 18.0
  # Characters set in the math font inside math{}. The letters an
  # expression question writes its unknown with (VARIABLE_NAMES in
  # db/alternators.py) must all be listed here, or the unknown would
  # be set in the text font while the expression around it is not.
  math_chars: xyzabcdefghijkmnpqrtuv
  narrow_space_fallback_ratio: 0.498

prices:
  # What a price finer than the cent meets with (8,208 €, from 3,6 kg at
  # 2,28 € a kg): error (refused), round_and_warn (8,21 €, and a warning),
  # round (8,21 €), warn (8,208 €, and a warning) or ignore (8,208 €).
  finer_than_cent: round_and_warn

rendering:
  color: "#222222"
  slide_number: "#ADADAD"
  grid:
    # How a grid document prints (its PDF); the screen rendering is left
    # alone. Any CSS length is accepted.
    # Margins of the printed sheet: one value for all four sides, or
    # "vertical horizontal".
    page_margin: "0.75cm"
    # Size of the question text on paper. The figures drawn inside a wording
    # are sized in em, so they follow it.
    font_size: "1rem"
    # Narrowest the answer column may get - the writing space of a page of
    # short numeric answers. A page whose answers are long words gets a wider
    # one, from the answers themselves.
    answer_col_min: "11rem"
  slideshow:
    # On-screen base text size for slideshow wordings/answers (any CSS length).
    # Per-question override: text_scale (a multiplier of this value).
    font_size: "4vw"
    # Vertical anchor of the content block (its top edge), as a CSS length.
    # Per-question override: raise (lifts the block up by that many %).
    content_top: "20%"
    # Spacing between wrapped / \n-separated wording lines (CSS line-height).
    # Per-question override: line_height.
    line_height: 1.3
    # Default for pic{}: when true the HTML is self-contained (SVG inlined,
    # raster images embedded as base64 data URIs); when false images are
    # referenced by their relative file name (the file must ship next to the
    # HTML). Per-pic override: include=true|false.
    include_pictures: false
  fractions:
    bar_thickness_ratio: 0.085
    bar_pad_v_ratio: 0.12
    bar_pad_h_ratio: 0.10
  sup:
    size_ratio: 0.65
    raise_ratio: 0.02
  angle:
    hat_height_ratio: 0.32
    hat_clearance_ratio: 0.06
    hat_stroke_ratio: 0.07
    ang_stroke_ratio: 0.09
    ang_right_margin: 0.84
    ang_width: 1.02
    ang_gap_ratio: 0.12
  tables:
    cell_pad_h_ratio: 0.15
    cell_pad_v_ratio: 0.15
    border_thickness: 1
    arrow_gap_ratio: 0.50
    arrow_extent_ratio: 1.4
    bubble_pad_ratio: 0.1
    bubble_auto_resize: 0.7
    bubble_thickness: 1.2
    arrowhead_size: 6.0
  spreadsheets:
    # An extract of a spreadsheet: the cells a formula reads, and the cell it
    # is typed in. Every size is a ratio of the surrounding font size, so the
    # figure follows the text it is set in — small in a worksheet, large on a
    # slide — with no per-layout value to keep in step.
    cell_pad_h_ratio: 0.45
    cell_pad_v_ratio: 0.22
    # Narrowest a data cell may get: a cell holding one digit still has to
    # read as a cell.
    cell_min_width_ratio: 2.4
    # Widest a cell may be made by the width reserved for a Q{} (see the
    # reserve= option). Past it, the answer has no place in the figure and
    # the question writes it under the picture instead.
    cell_max_width_ratio: 6.0
    # Narrowest the column of row numbers may get.
    header_min_width_ratio: 1.5
    # Background of the two header bands (column letters, row numbers).
    header_bg: "#e9e9e9"
    # Colour of the thin lines ruling them — lighter than the cell grid, so
    # the eye reads the cells first and the references second.
    header_line: "#a0a0a0"
    header_thickness: 1.0
    # Stroke of the cell grid itself.
    border_thickness: 1.4
    # Outline of the cell named by select=, as a spreadsheet outlines the
    # selected one.
    select_thickness: 2.4
    select_color: "#1F5C99"
  bar_models:
    total_width_ratio: 14.0
    height_ratio: 1.6
    border_thickness: 1
    cell_pad_h_ratio: 0.15
    cell_pad_v_ratio: 0.15
    brace_gap_ratio: 0.25
    brace_height_ratio: 0.35
    brace_thickness: 1.2
    brace_label_gap_ratio: 0.15
    # Softness of the corner curls (foot endpoints) and the central cusp.
    # 0 = vertical tangents (sharpest); 1 ≈ 45° tangents (softest).
    brace_foot_softness: 0.5
    brace_cusp_softness: 0.5
    # Thickness of the inner sub-grid lines (`split=R×C` option), relative
    # to the outer border_thickness. 1.0 = same; <1.0 = lighter ruling.
    split_thickness_ratio: 1.0
    # Height of a tape (brace_top_style=tape / brace_bot_style=tape),
    # relative to the main bar height. 1.0 = same height as the main bar.
    tape_height_ratio: 1.0
    tape_gap_ratio: 0.0
  barchart:
    bar_width_ratio: 1.6        # default bar width (× font size)
    bar_spacing_ratio: 1.2      # minimum gap between bars (× font size)
    max_bar_width_ratio: 3.0    # maximum bar width (× font size)
    chart_height_ratio: 9.0     # height of the plotting area (× font size)
    bar_color: "#1F5C99"        # default inner colour of the bars
    axis_thickness: 1.2         # axis stroke width (px)
    grid_thickness: 1.0         # grid line stroke width (px)
    grid_opacity: 0.6           # default opacity of x_grid / y_grid lines
    grid_secondary_opacity: 0.3 # opacity of y_grid lines at unlabelled grads
    tick_len_ratio: 0.3         # length of a minor Y tick mark (× font size)
    major_tick_len_ratio: 0.55  # length of a labelled Y tick mark (× font size)
    tick_spacing_ratio: 0.0     # min spacing between graduations (× font size; 0=off)
    label_gap_ratio: 0.25       # gap between axis and labels (× font size)
    target_ticks: 5             # targeted number of Y graduations (nice step)
  axis:
    length_ratio: 15.0          # nominal length of the axis, first to last
                                # graduation (× font size); what a figure of
                                # the usual number of graduations takes. It is
                                # held between the two spacings below, so an
                                # axis of few graduations comes out shorter
                                # and one of many comes out longer
    line_ratio: 23.0            # width of the line an axis shares with the
                                # sentence set after it (beside=), in font
                                # sizes: the axis is shortened to leave the
                                # sentence room, as measured in the render's
                                # font. What a grid wording has on screen,
                                # where it is narrowest (~24.2), less a little
                                # slack
    thickness: 1.2              # stroke width of the line and graduations (px)
    tick_len_ratio: 0.34        # length of a sub-graduation (× font size)
    major_tick_len_ratio: 0.62  # length of a written graduation (× font size)
    tick_spacing_ratio: 0.6     # closest two consecutive graduations may come
                                # (× font size); the axis is lengthened rather
                                # than let them, since an axis is read by
                                # counting its graduations and a comb is not
                                # counted (0 = no floor)
    max_tick_spacing_ratio: 1.6 # widest they may be spread (× font size); the
                                # axis is shortened rather than let five
                                # graduations take the width of twenty
                                # (0 = no ceiling)
    label_gap_ratio: 0.22       # gap between a graduation and its value
                                # (× font size)
    # Size of what is written along an axis (the values of the graduations,
    # the names of the points), relative to the text around it — the same
    # convention as a polygon's labels.
    label_scale: 0.8
    point_mark_ratio: 0.42      # size of the cross marking a point
                                # (× font size)
    point_mark_thickness: 1.4   # stroke width of that cross (px)
    name_gap_ratio: 0.18        # gap between a point and its name
                                # (× font size)
    arrowhead_ratio: 0.42       # length of the arrowhead (× font size)
    end_gap_ratio: 0.9          # blank between the last graduation and the
                                # arrow tip (× font size)
  plot:
    # Size the whole figure is drawn at, as a factor. `scale` is the default,
    # which a `scale_<layout>` key overrides for one kind of page: grid (a
    # worksheet), page or slide — whose text is set large enough to be read
    # from the back of the room, and would make the figure fill the screen.
    # A `scale_<layout>_print` or `scale_<layout>_screen` key overrides that
    # in turn, on paper or on screen only: a printed sheet counts its height,
    # a screen is read from further away. The figure is drawn at its print
    # size, and enlarged (or shrunk) on screen by the stylesheet of the page.
    # `scale_<layout>_small_screen` is the screen size below 768 px — a phone,
    # which has no room for a large figure beside its sentence; left out, the
    # screen size applies there too.
    scale: 1.0
    scale_slide: 0.85
    scale_grid: 0.7
    scale_grid_screen: 1.2
    scale_grid_small_screen: 1.0
    cell_size_ratio: 0.6        # side of a cell of the grid (× font size);
                                # widened where the written values would touch
    thickness: 1.2              # stroke width of the axes and their ticks (px)
    grid_thickness: 0.6         # stroke width of the grid (px)
    grid_color: "#9a9a9a"       # colour of the grid
    subgrid_thickness: 0.4      # stroke width of the sub-grid that
                                # x_subdivisions / y_subdivisions draw (px)
    subgrid_color: "#cfcfcf"    # colour of that sub-grid
    tick_len_ratio: 0.24        # length of the tick at a written value
                                # (× font size)
    sub_tick_len_ratio: 0.14    # length of the tick at a subdivision, when
                                # subdivision_marks is on (× font size)
    label_gap_ratio: 0.07       # gap between an axis and the values written
                                # along it (× font size)
    label_spacing_ratio: 0.14   # least blank between two values written side
                                # by side (× font size); the cells are widened
                                # rather than let them come closer
    # Size of what is written in the figure (the values along the axes, the
    # names of the points), relative to the text around it.
    label_scale: 0.7
    point_color: "#B5251C"      # default colour of a point and of its name
                                # (mathmaker's red)
    point_mark_ratio: 0.36      # size of the cross marking a point
                                # (× font size)
    point_mark_thickness: 1.4   # stroke width of that cross (px)
    name_gap_ratio: 0.04        # gap between a point's cross and its name
                                # (× font size)
    arrowhead_ratio: 0.2        # length of an arrowhead (× font size): TikZ's
                                # curved tip, as mathmaker drew it
    curve_color: "#1F5C99"      # default colour of a curve (and of its name)
    curve_thickness: 1.5        # stroke width of a curve (px)
    curve_samples: 12           # points a curve is computed at, per cell
    max_labels: 10              # most values written along an axis when its
                                # x_labels_step / y_labels_step is not given:
                                # it is then the finest of 1, 2, 5, 10, 20…
                                # graduations that writes no more
  rectgrids:
    # Side of one cell (× font size). `cell_size_ratio` is the default, which
    # a `cell_size_ratio_<layout>` key overrides for one kind of page: grid
    # (a worksheet), page or slide.
    cell_size_ratio: 0.8
    cell_size_ratio_slide: 1.35
    thickness: 1.0              # stroke width of the ruling (px)
    # Colour of the coloured cells. `fill_color` is the default, which a
    # `fill_color_<layout>` key overrides for one kind of page: grid (a
    # worksheet, printed in black and white for an assessment), page or
    # slide. "random" draws a colour from `fill_palette` for each figure.
    # A question asks about the "greyed" part of a grey figure and the
    # "coloured" part of any other, so grey is what reads unambiguously on
    # paper.
    fill_color: "lightgray"
    fill_color_slide: "random"
    fill_palette: ["#eba215", "#6fb7e0", "#8cc63f", "#f28c8c", "#b39ddb",
                   "#ffd54f"]
    # Colour the "complement" strategy paints back over the filled grid:
    # it stands for the empty cells, so it must match what the figure sits
    # on — white, unless a page says otherwise.
    background_color: "white"
  polygons:
    unit_size_ratio: 1.0        # size of one construction unit (× font size)
    thickness: 1.2              # stroke width of the sides (px)
    label_gap_ratio: 0.15       # gap between a side and its label (× font size)
    # Size of what is written next to a figure (side labels, vertex names,
    # centre content), relative to the text around it: the dimensions of a
    # figure are written smaller than the wording that carries it.
    label_scale: 0.75
    vertex_name_gap_ratio: 0.25 # gap between a vertex and its name (× font size)
    right_angle_size_ratio: 0.38  # side of the right-angle coding (× font size)
    diagonal_dash: "4 3"        # dash pattern of a dashed diagonal
    side_mark_size_ratio: 0.30  # length of an equal-sides tick (× font size)
    side_mark_gap_ratio: 0.11   # spacing between the ticks of a double or
                                # triple mark, along the side (× font size)
    # Construction sizes (in units, i.e. in em of the surrounding text), per
    # layout, with the band their width/height ratio is kept within. A grid
    # shares its height between a dozen questions, so its figures stay small
    # and lie flatter than elsewhere; a slide holds a single one.
    build:
      grid:
        w: [3.0, 4.5]
        h: [1.05, 1.25]
        ratio: [2.0, 4.0]
      page:
        w: [9.0, 12.0]
        h: [5.0, 7.0]
        ratio: [1.3, 2.3]
      slide:
        w: [4.8, 6.4]
        h: [2.8, 4.0]
        ratio: [1.3, 2.3]
    # How much room a polygon built from its sides may take, per layout.
    # Unlike `build` above — which draws a rectangle's two dimensions
    # independently, the figure saying nothing about its labels — such a
    # polygon is scaled by a single factor: stretching it along one axis would
    # undo the equal sides it is labelled with. So these are plain maximum
    # extents, and the figure keeps whatever proportions its sides gave it.
    # A grid affords more height here than it does to a rectangle: a hexagon
    # carrying six labels cannot be made to lie flat.
    fit:
      grid:
        w: 4.6
        h: 2.6
      page:
        w: 11.0
        h: 7.0
      slide:
        w: 6.4
        h: 4.2
    # A figure carrying a length on every side needs more room than the same
    # figure carrying two: the labels sit at the middles of the sides and keep
    # their size whatever the drawing does, so on a small polygon they meet.
    # A fitted figure is therefore allowed to grow past its band, by steps,
    # until nothing written beside it lands on anything else — and no further
    # than `max` times the band, past which the crowding is the question's
    # fault and not the layout's.
    fit_growth:
      max: 2.8
      step: 0.1

numrange:
    threshold: 10000

db:
    reset_ratio: 0.66
    tracking_max_entries: 100

sources:
    generative_cache_size: 20

logging:
  log_dir: /var/log/automath
  log_level: INFO
  max_bytes: 1 # MB
  backup_count: 9
  log_to_console: True