Skip to content
All articles Article

Content formatting reference

A visual reference for typography, lists, code, mathematics, images and video in MDX.

7 min read
  • reference
  • formatting
Sample cover image
On this page

This page collects examples for checking our content styles. Compare them in light and dark mode, on a narrow screen and on a wide screen.

Text and headings

A regular paragraph should have comfortable line spacing. Bold text, italic text, bold italic text, strikethrough and inline code should remain easy to distinguish.

A second paragraph checks the space between paragraphs. Here is an external link to Astro, an internal link to the roadmap, and a link to the mathematics section.

A deliberate line break ends here.
This continues on the next line within the same paragraph.

Third-level heading

A short paragraph under a subsection.

Fourth-level heading with inline code

A short paragraph under a smaller subsection.

Fifth-level heading

A short paragraph under a fifth-level heading.

Sixth-level heading

A short paragraph under the smallest heading. The page title supplies the first-level heading.

Lists

  • Physical quantities
    • Length and time
    • Mass and temperature
  • Motion
    • Position and displacement
    • Velocity and acceleration
  1. Choose a system.
  2. Identify the quantities.
    1. Record known values.
    2. Identify the unknown value.
  3. Check the units.
  • Read the definitions.
  • Check the examples.
    • Constant velocity
    • Constant acceleration
  • Revisit the assumptions.

Definitions

Use Definition for a mathematical definition. Its optional title names the concept; the content supports Markdown and mathematics.

MDX
<Definition title="Unit vector">
 
A **unit vector** is a vector whose norm is one:
 
$$
\lVert\mathbf{u}\rVert=1.
$$
 
</Definition>
Definition Unit vector

A unit vector is a vector whose norm is one:

∥u∥=1.\lVert\mathbf{u}\rVert=1.

Quotes and callouts

A quoted paragraph can contain emphasis, a link, and inline mathematics such as v=d/tv = d/t.

A second paragraph checks spacing within the quotation.

  • First quoted item

  • Second quoted item

A nested quotation checks indentation.

Callout colours and icons

Use color to choose a palette colour and icon to choose an SVG from src/assets/icons, without its .svg extension. Omitting them gives a neutral callout with the information icon.

MDX
<Callout title="Explore further" color="purple" icon="arrow-up-right">
 
Follow this connection when you are ready.
 
</Callout>

Tables

QuantitySymbolSI unit
Distanceddmetre
Timettsecond
Speedvvmetre per second
ItemDescription
AssumptionConstant speed throughout the interval
distanceA variable in the code example
RoadmapA link inside a table

Code

Inline code: distance = speed * time.

Pythonmotion.py
speed = 2
time = 3
distance = speed * time
print(f"Distance: {distance} m")
JavaScript
const speed = 2;
const time = 3;
console.log(speed * time);
TEXT
Plain text without syntax highlighting.
A long line checks horizontal scrolling: distance_covered_during_the_first_interval + distance_covered_during_the_second_interval + distance_covered_during_the_third_interval
ANSI
PASS Equation rendered
CHECK Narrow-screen spacing

Mathematics

Inline mathematics

Simple notation should sit comfortably in a sentence: xx, 00, x2x^2, ana_n, α\alpha, and v\mathbf{v}.

A fraction a+bc\dfrac{a+b}{c} and a root x2+y2\sqrt{x^2+y^2} check different inline heights.

Longer expressions use display blocks so they do not crowd a paragraph:

lim⁡x→0sin⁡xx=1\lim_{x\to 0}\dfrac{\sin x}{x}=1
f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x)=\lim_{h\to 0}\dfrac{f(x+h)-f(x)}{h}

A speed of 2 m/s2\,\mathrm{m/s} checks text inside mathematics.

Display mathematics

This unnumbered equation checks the default display layout:

∫0Tv(t) dt=x(T)−x(0)\int_0^T v(t)\,\mathrm{d}t = x(T)-x(0)

Numbered equations and references

The reference to equation (2) points forward. References should resolve regardless of where they appear in this post.

d=vtd = vt
(1)

Equation (1) relates distance, speed and time for constant speed.

K=12mv2K = \dfrac{1}{2}mv^2
(2)

Compare equations (1) and (2). Repeated references should retain the same numbers.

Labels and references use our custom plugin. Labels go inside display math; references go directly in prose. This code block shows the source literally:

LATEX
$$
d = vt
\label{sample-distance}
$$
 
See equation \eqref(sample-distance).

Aligned equations

v(t)=v0+atx(t)=x0+v0t+12at2\begin{aligned} v(t) &= v_0 + at \\ x(t) &= x_0 + v_0t + \dfrac{1}{2}at^2 \end{aligned}
(3)

Equation (3) gives two relations in one numbered block.

A derivation with one number

Use equation with split when several lines describe one derivation. The whole block receives one number.

ΔK=∫x0x1F dx=m∫v0v1v dv=12m(v12−v02)\begin{equation*} \begin{split} \Delta K &= \int_{x_0}^{x_1} F\,\mathrm{d}x \\ &= m\int_{v_0}^{v_1} v\,\mathrm{d}v \\ &= \dfrac{1}{2}m(v_1^2-v_0^2) \end{split} \end{equation*}
(4)

Equation (4) is the work–energy theorem for a particle of constant mass.

Aligned equations with separate numbers

Use align to number each row. Place a label on each row you want to reference. These numbers continue from the earlier equations in this post.

v(t)=v0+at(5)x(t)=x0+v0t+12at2(6)v2−v02=2a(x−x0)(7)\begin{align*}v(t) &= v_0 + at\tag{5}\\ x(t) &= x_0 + v_0t + \dfrac{1}{2}at^2\tag{6}\\ v^2-v_0^2 &= 2a(x-x_0)\tag{7}\end{align*}

Equation (5) gives velocity, equation (6) gives position, and equation (7) eliminates time. Each link points to its own row.

LATEX
$$
\begin{align}
v(t) &= v_0 + at \label{velocity} \\
x(t) &= x_0 + v_0t + \dfrac{1}{2}at^2 \label{position}
\end{align}
$$
 
See equations \eqref(velocity) and \eqref(position).

In prose, use \eqref(label) with parentheses so MDX does not treat braces as JavaScript. Our plugin resolves the labels before KaTeX renders the mathematics. Missing or duplicate labels stop the build.

Skipping a row number

Use \notag or \nonumber to skip a row. Use align* for an unnumbered group, or aligned for several lines sharing one label.

(a+b)2=a2+2ab+b2(a−b)2=a2−2ab+b2(8)\begin{align*}(a+b)^2 &= a^2+2ab+b^2 \notag\\ (a-b)^2 &= a^2-2ab+b^2\tag{8}\end{align*}

Only equation (8) receives a number in this group.

Matrices and piecewise functions

A=(123456789)x=[x1x2x3]\mathbf{A} = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \qquad \mathbf{x} = \begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}
∣x∣={x,if x≥0,−x,if x<0.|x| = \begin{cases} x, & \text{if } x \geq 0, \\ -x, & \text{if } x < 0. \end{cases}

Sums, operators and accents

∑n=0∞xnn!=ex∇⋅E=ρε0n^⋅v⃗=vn\sum_{n=0}^{\infty}\dfrac{x^n}{n!}=e^x \qquad \nabla\cdot\mathbf{E}=\dfrac{\rho}{\varepsilon_0} \qquad \hat{\mathbf{n}}\cdot\vec{v}=v_n

Mathematics in other content

  • A list item with Δx=x2−x1\Delta x = x_2-x_1.
  • A checklist can include a mathematical expression:
    • Evaluate ∫01x2 dx\int_0^1 x^2\,\mathrm{d}x.

The expression dxdt\dfrac{\mathrm{d}x}{\mathrm{d}t} should keep its mathematical formatting inside a quotation.

Wide equation

This deliberately long equation checks horizontal overflow on small screens:

(a+b+c+d+e+f)2=a2+b2+c2+d2+e2+f2+2ab+2ac+2ad+2ae+2af+2bc+2bd+2be+2bf+2cd+2ce+2cf+2de+2df+2ef(a+b+c+d+e+f)^2 = a^2+b^2+c^2+d^2+e^2+f^2+2ab+2ac+2ad+2ae+2af+2bc+2bd+2be+2bf+2cd+2ce+2cf+2de+2df+2ef

Images and video

Sample image for checking width, borders and spacing

The paragraph after the image checks the return to regular text spacing.

The video should keep its proportions as the page narrows and load lazily.

Footnotes

This sentence has a short footnote.1 This one has a longer footnote.2 The short footnote is referenced again here.1

Definitions and disclosure

This definition list uses explicit MDX markup, rather than unsupported Markdown definition-list syntax.

Displacement
The change in position between two points in time.
Velocity
The rate of change of position with time.
Open a native disclosure

This checks ordinary HTML embedded in MDX, including emphasis and a link.

Separators and characters

A paragraph before a horizontal rule.


A paragraph after the rule. Unicode examples: α β γ, ©, →, ±, ×, and °. Emoji examples: 🔬 🧮 💡 ✅ ❌ ❤️.

Footnotes

  1. A short footnote with a roadmap link. ↩ ↩2

  2. A footnote containing bold text, inline code, and mathematics v=d/tv=d/t. ↩

Finished readingBrowse all articles