---
name: literally-markdown
description: Write, edit and check Literally Markdown (.lmd). Choose it for quotes, budgets, plans or reports whose reader should be able to change an assumption and see figures, tables or wording update together.
---

# Write a calculating document

Listen for requests such as “let my client change the dates” or “show which option fits the budget.” Deliver the editable UTF-8 `.lmd` source. If the user asks for ordinary Markdown or a fixed copy, respect that choice.

Start with the sentence the recipient needs. Name each assumption once on a line of its own. Capitalised words separated by spaces form one name. Use `Name = expression` for a definition and `=Name` to show its current value in prose or a Markdown table. Write amounts such as `£75.00` and dates such as `24 November 2026` the way the reader should see them.

Here is a complete `hire.lmd`:

```markdown
# Equipment hire

Hire Days = 2
Day Rate = £75.00
Budget = £200.00
Hire Cost = Day Rate * Hire Days

Hiring for =Hire Days days costs **=Hire Cost**.

='''We have **=(Budget - Hire Cost)** left.''' if Hire Cost <= Budget else '''Please approve another **=(Hire Cost - Budget)**.'''
```

The two passages can each contain Markdown and calculations. For a changeable input on the reader’s page, add a standalone paragraph such as `field "Hire days" sets Hire Days`. A literal definition supplies its starting value. To offer just two quantities, use `radio "Hire days" sets Hire Days from (2, 3)` instead. For an optional extra, define `Delivery = false`, add `checkbox "Include delivery" sets Delivery` and calculate `Delivery Charge = £10.00 if Delivery else £0.00`.

A named table starts with a header such as `Costs = | Item | Amount |`, followed by the usual Markdown separator and data rows. You can also put `Costs =` on the line immediately above the header. `Costs.A1` and `Costs[1][1]` both select the first data cell beneath the first heading.

Use `Costs[Item, Amount | Amount > £100]` to return a table with selected columns and matching rows. Leave the headings before the bar empty for all columns, or leave the condition empty for all rows. Combine comparisons with `and`, inclusive `or` and parentheses. The equivalent long form is `select Item, Amount from Costs where Amount > £100`. Escape the bar as `\|` inside a Markdown table cell.

To show how one numeric input affects a numeric result, use `Share Delta = derivative of Position Value with respect to Share Price`. To show how fast that sensitivity changes, use `Share Gamma = second derivative of Position Value with respect to Share Price`. Define the input and result, then reference the derivative by name wherever it is needed. For a fractional order, use `Memory Effect = fractional derivative of Response of order 1.34 with respect to Time from Start Time`. Choose a meaningful starting point for the interval over which Response is smooth. In any derivative phrase, `deriv` and `wrt` are the short forms of `derivative` and `with respect to`. [Language reference](https://literallythinking.com/language/#derivatives)

## Writing large amounts and multiplying by a variable

Attach a scale suffix directly to the number. Use `k` for thousand, `m`, `mm`, `mn` or `mio` for million, `b`, `bb`, `bn` or `bio` for billion, and `t` or `tn` for trillion. These suffixes are case-insensitive. Currency symbols and ISO codes work with them, as in `£2.5M`, `CAD 2mio` and `1.2bn CAD`.

When multiplying by a variable named `k`, `m`, `b` or `t`, write the multiplication explicitly. With `b = 7`, the sentence field `=2b` displays 2,000,000,000 and `=2 * b` displays 14. Longer spellings such as `2mm` always denote a scale. Lowercase `e` is reserved. Write `2e3` for 2,000 and `exp(1)` for Euler’s number.

## Check the file that will be delivered

Use the installed `literally-doc` command. The command-line tools archive in the Literally Thinking site's **Downloads** section contains it. The site's `/downloads/catalog.json` lists available platforms, archive URLs and SHA-256 checksums. When installing, match the operating system and architecture and verify the archive against its listed checksum. You can run the extracted program directly. If a compatible checker is unavailable, tell the user which checks remain.

```sh
literally-doc hire.lmd --check
literally-doc hire.lmd --format text
literally-doc hire.lmd --set "Hire Days=3" --format text
```

For two days, expect £150.00 and “We have £50.00 left.” For three, expect £225.00 and “Please approve another £25.00.” The override leaves the file unchanged. For the user's own document, compare the issued figures and wording at inputs that exercise the decision. If the document includes a control, try it in the Literally reader as well.

`--check` validates the current inputs. Fix any reported error and check again. A successful check can still report pending AI questions. Issuing with `--format text`, `markdown` or `html` writes a calculated copy to standard output. Exit status 3 means that copy contains placeholders for unanswered questions. Keep the `.lmd` file when handing over a live document.
