Complete reference for using Verified Calculations in your Quarto documents.
Verified Calculations provides three main components for Quarto:
The workflow is: define formulas, request calculations, insert results. The calculation service handles the maths.
Use eq to render a formula from the library. The formula is displayed as LaTeX maths.
{{< eq id="formula:velocity-time" >}}
This renders the velocity-time equation: v = u + at
| Parameter | Required | Description |
|---|---|---|
id | Yes | Formula ID from the library (e.g., formula:velocity-time) |
Browse the formula library to find formula IDs.
Use a .calc-request div to define inputs for evaluation. This tells the service what to compute.
::: {.calc-request}
request_id: "example-01"
formula_id: "formula:velocity-time"
solve_for: "v"
inputs:
u: { value: 0, unit: "m/s" }
a: { value: 9.8, unit: "m/s^2" }
t: { value: 3, unit: "s" }
options:
sigfigs: 3
show_steps: true
:::
| Field | Required | Description |
|---|---|---|
request_id | Yes | Unique ID to reference this calculation |
formula_id | Yes | Formula to evaluate |
solve_for | Yes | Variable to solve for (e.g., "v", "t", "a") |
inputs | Yes | Known values with units |
options | No | Formatting options |
| Option | Default | Description |
|---|---|---|
sigfigs | 3 | Significant figures (1-6) |
show_steps | true | Include working steps |
format | "tex" | Output format: "tex" or "text" |
Use calc to insert computed values from a calculation request.
The final velocity is {{< calc request="example-01" >}}.
{{< calc request="example-01" field="result.value" >}} m/s
{{< calc request="example-01" field="steps" >}}
| Parameter | Required | Description |
|---|---|---|
request | Yes | The request_id from a calc-request block |
field | No | What to display (default: "result.fmt") |
| Field | Description |
|---|---|
result.fmt | Formatted result with unit (default) |
result.value | Numeric value only |
result.unit | Unit only |
steps | Working steps as aligned equations |
latex | The formula's LaTeX |
Add an interactive widget for readers to try calculations themselves:
{{< calc-playground >}}
This renders a form where users can select a formula, enter inputs, and see results in real-time.
There are two ways to use Verified Calculations:
Evaluate all calculations before Quarto renders. Results are cached in site_data/calcs.json.
# In _quarto.yml
project:
pre-render:
- physics-calc pre-render --root . --api https://mentormind-calc.fly.dev --out site_data/calcs.json
The playground widget calls the service directly from the browser. No pre-render needed for interactive use.
projectile-height-01 not calc1problem-2a, problem-2b, problem-2cFor worked examples, show the steps:
**Working:**
{{< calc request="example-01" field="steps" >}}
You can have multiple calc-request blocks in one document. Each needs a unique request_id.
If a calculation fails, the output shows [calc missing request-id:field]. Check: