Writing like a paper

·3 min read

Contents8 sections

A paper has habits a blog usually drops: numbered statements, references that say "Figure 2" and stay right, notes in the margin, algorithms set between two rules. This post shows each one, in the Markdown that writes it. The numbers in the chart are made up for the example.

References that write themselves

A link with no text to something the post numbers fills in its name. As Figure 2 shows, warm-up reaches a lower loss; Theorem 2 is the rule behind (1), and Algorithm 1 is the update. A link to a heading reads the heading: see Sidenotes.

As [](#fig-loss) shows, … [](#thm-bayes) … [](#eq-bayes) … [](#alg-sgd)

It works for figures, tables, listings, notebooks, algorithms, theorem-like blocks and equations. A link with words of its own is left as written, and a name the post does not have reads "??", and the build says which.

Theorems and proofs

Written as an alert is, with the kind in brackets. The rest of the first line is the title, and {#name} names the block for links.

Definition 1 (Posterior). The posterior is the distribution of the parameters given the data, p(θ∣y)p(\theta \mid y).

Theorem 2 (Bayes' rule). For events AA and BB with P(B)>0P(B) > 0,

P(A∣B)=P(B∣A) P(A)P(B)(1)P(A \mid B) = \frac{P(B \mid A)\, P(A)}{P(B)} \tag{1}

Proof of Theorem 2. By the definition of conditional probability, P(A∩B)=P(A∣B) P(B)=P(B∣A) P(A)P(A \cap B) = P(A \mid B)\,P(B) = P(B \mid A)\,P(A). Divide by P(B)P(B). ∎

Remark 3. Definition 1 is Theorem 2 with AA the parameters and BB the data.

> [!THEOREM] Bayes' rule {#thm-bayes}
> For events $A$ and $B$ with $P(B) > 0$, …

> [!PROOF] of [](#thm-bayes)
> By the definition of conditional probability, …

The kinds are theorem, lemma, proposition, corollary, conjecture, definition, example, remark and proof. All but the proof share one count, so a reader looking for "2" finds one thing; a proof ends with a tombstone.

Sidenotes

Footnotes are written as they always are.11 Like this one. Nothing in the Markdown changes. On a screen wide enough to have a margin, a note stands beside the line that cites it; on a narrower one it is at the foot of the post, where a footnote goes.22 The page carries the note in both places and shows one of them, so a screen reader meets it once. A note that holds a list or code stays at the foot on every screen.3

Algorithms

The algorithmicx syntax, in a fence, set at build time with KaTeX for the maths. \label{sgd} names it for a link.

Algorithm 1 Stochastic gradient descent

Require: step size η\eta, initial θ0\theta_0

1t←0t \gets 0

2while not converged do

3sample a minibatch BtB_t

4θt+1←θt−η∇LBt(θt)\theta_{t+1} \gets \theta_t - \eta \nabla L_{B_t}(\theta_t)

5t←t+1t \gets t + 1

6end while

7return θt\theta_t

Pictures in TikZ

TikZ in a fence, drawn by TeX at build time with no TeX installed. Black is the page's ink and white its background, so the picture follows the theme.

Figure 1. A loss falling exponentially towards its floor bb.

Charts

A Vega-Lite spec in a fence. The page arrives with the chart drawn; pointing at it loads the charting library and makes it live, with tooltips. The data, read here from a CSV beside the post, is under it as a table.

01002003004005006007008009001,0001,1001,2001,3001,4001,5001,6001,7001,8001,9002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
02004006008001,0001,2001,4001,6001,8002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
02004006008001,0001,2001,4001,6001,8002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
01002003004005006007008009001,0001,1001,2001,3001,4001,5001,6001,7001,8001,9002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
02004006008001,0001,2001,4001,6001,8002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
02004006008001,0001,2001,4001,6001,8002,000Training step1.01.52.02.53.0Validation lossconstantwarm-upSchedule
Data (42 rows)
stepscheduleloss
0constant3.22
0warm-up3.15
100constant2.947
100warm-up3.07
200constant2.702
200warm-up2.949
300constant2.483
300warm-up2.591
400constant2.287
400warm-up2.287
500constant2.112
500warm-up2.028
600constant1.955
600warm-up1.808
700constant1.815
700warm-up1.621
800constant1.689
800warm-up1.461
900constant1.576
900warm-up1.326
1000constant1.476
1000warm-up1.21
1100constant1.386
1100warm-up1.112
1200constant1.305
1200warm-up1.028
1300constant1.233
1300warm-up0.957
1400constant1.169
1400warm-up0.896
1500constant1.111
1500warm-up0.845
1600constant1.059
1600warm-up0.801
1700constant1.013
1700warm-up0.763
1800constant0.972
1800warm-up0.732
1900constant0.935
1900warm-up0.705
2000constant0.902
2000warm-up0.682
Figure 2. Validation loss with a constant learning rate and with warm-up.

Chemistry

\ce and \pu inside maths: CX6HX12OX6+6 OX2→6 COX2+6 HX2O\ce{C6H12O6 + 6 O2 -> 6 CO2 + 6 H2O}, with ΔH=−2870 kJ/mol\Delta H = \pu{-2870 kJ/mol}, and ions such as SOX4X2−\ce{SO4^2-}.

Code that shows what changed

{5, 2-3} after the language marks those lines, a single line or a range, in any order:

def loss(model, batch):
    logits = model(batch.x)
    y = 3
    z = 45 / y
    return cross_entropy(logits, batch.y)

diff-python marks what a change adds and removes, highlighted as Python. The copy button copies the code after the change.

def step(model, batch, optimiser):
    loss = loss_fn(model, batch)
    with autocast():
        loss = loss_fn(model, batch)
    loss.backward()

Fences that each name a tab and follow one another become one set of tabs. Picking a language in one set picks it in every set, and the page remembers.

Listing 1. The same model in two languages.
model = LogisticRegression().fit(X, y)
model <- glm(y ~ ., data = d, family = binomial)

Footnotes

  1. Like this one. Nothing in the Markdown changes. ↩

  2. The page carries the note in both places and shows one of them, so a screen reader meets it once. ↩

  3. Because a list does not fit a 13rem margin:

    • the margin is for a sentence or two;
    • anything longer reads better at the foot. ↩
Cite this post
BibTeX
@misc{soleimanzadeh2026writing,
  author  = {Soleimanzadeh, Kiarash},
  title   = {Writing like a paper},
  year    = {2026},
  url     = {https://blog.kiarashs.ir/blog/writing-like-a-paper},
  urldate = {2026-03-30}
}
APA
Soleimanzadeh, K. (2026, March 30). Writing like a paper. Kiarash Soleimanzadeh. https://blog.kiarashs.ir/blog/writing-like-a-paper
IEEE
K. Soleimanzadeh, "Writing like a paper," Kiarash Soleimanzadeh, Mar. 30, 2026. [Online]. Available: https://blog.kiarashs.ir/blog/writing-like-a-paper
Plain text
Kiarash Soleimanzadeh. “Writing like a paper.” Kiarash Soleimanzadeh, 30 March 2026. https://blog.kiarashs.ir/blog/writing-like-a-paper

Kiarash Soleimanzadeh

Comments