Foundations to Frontier
Tests
O. Research Skills › O3 Communicating Research

LaTeX and Overleaf

LaTeX is the typesetting system of most mathematical and machine-learning papers; Overleaf is a shared online editor for it. Beyond the markup, the craft is in the workflow: tables and numbers generated from results, a clean bibliography, and source that co-authors can edit together. The exercises generate booktabs tables and BibTeX entries from code, then simulate bibliographies of 300 papers assembled from two tools, with duplicate entries for about 30% of papers and follow-up papers with nearly the same title, and compare four ways of finding duplicates: citation keys found about a quarter and merged distinct papers, DOIs were exact but found only a fifth to a quarter, normalised titles found three quarters, and fuzzy title matching found nearly all but merged some follow-ups. Practice problems cover bolding the best result, citation key collisions, numbers kept as macros, matching thresholds, and one sentence per line.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

The paper as a program

A LaTeX paper is source code: it compiles into a PDF, it can be versioned, and much of it can be generated. Results tables, the numbers quoted in the text and the bibliography all change many times before submission. Typing them by hand invites stale numbers and duplicate references; generating them from the results and from clean metadata keeps the paper consistent with the work.

🎮 Research lab

300 papers, about 94 with a second, differently formatted entry, and 15% follow-up papers with nearly the same title. Click a rule:

Merges distinct papers: 10.8% of merged pairs are wrong. Finds nearly every duplicate.

Why engineers care

In Exercise 2, matching normalised titles found 76.3% of duplicate entries while merging almost no distinct papers; fuzzy matching found 99.8% but 13.7% of the pairs it merged were different papers.

📝 Quick check (Level 0)
0/3 answered
  1. 1. LaTeX source is best treated like…
  2. 2. Numbers in the text of a paper should ideally be…
  3. 3. A duplicate bibliography entry usually arises from…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Structure: a preamble (document class, packages, macros) and a body of sections, floats (figures and tables), equations and citations; labels and references number everything automatically.
  • Special characters: ten characters (ampersand, percent, dollar, hash, underscore, the two braces, tilde, caret and backslash) must be escaped in text.
  • Tables: the booktabs package: three horizontal rules (top, mid, bottom), no vertical rules, units in the header, the same number of decimals in a column.
  • Bibliographies: BibTeX or biblatex entries with a key, type and fields; cite by key; protect capitals in titles by wrapping the word in braces; prefer the published version and include DOIs.
  • Macros for results: a script writes a file of commands such as a macro holding the accuracy, and the text uses the macro, so every quoted number updates when results change.
  • Collaboration: Overleaf or git; one sentence per line keeps edits on separate lines, so simultaneous changes rarely conflict.
📝 Quick check (Level 1)
0/3 answered
  1. 1. The booktabs style for tables uses…
  2. 2. Braces around a word in a BibTeX title…
  3. 3. Writing one sentence per line helps because…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Generating tables and cleaning bibliographies

Exercise 1.

  • Escape the ten special characters.
  • Generate a booktabs table of mean ± standard deviation with the best mean in each column in bold.
  • Write BibTeX entries from dicts and parse them back from text.

Practice.

  • Generate every table and quoted number from the results files; never retype them.
  • Bold a result only when the difference is real, or bold all methods within the noise of the best.
  • Clean the bibliography before submission: one entry per paper, the published version, DOIs, protected capitals.
  • Deduplicate with care: match on DOI first, then normalised titles, and check fuzzy matches by hand.
  • Write one sentence per line in shared source.
def pairs_by(es, method, threshold=0.7):
    for a, b in all_pairs(es):
        if method == "doi":   hit = a.doi and a.doi == b.doi
        if method == "title": hit = norm(a.title) == norm(b.title)
        if method == "fuzzy": hit = (a.author == b.author and abs(a.year - b.year) <= 1
                                     and jaccard(a.title, b.title) >= threshold)
🐍 Exercise 1: LaTeX from code
Write an escaper, a booktabs table generator with the best result in bold, and a BibTeX writer and parser.
📝 Quick check (Level 2)
0/3 answered
  1. 1. In Practice 1, the single bolded best was truly best in about…
  2. 2. In a bibliography of 1,000 entries, author-year keys were shared by about…
  3. 3. Simultaneous edits by two co-authors conflicted in Practice 5 about…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

What each rule can find. A DOI match needs both entries to carry the DOI: with each present with probability 0.5, it finds at most 0.5² = 25% of duplicates, but never merges different papers. An exact normalised title match finds every duplicate whose title was not revised, here 1 − 0.25 = 75%. Fuzzy matching finds revised titles too, at the price of also matching distinct papers whose titles differ by a word.

Key collisions. If keys are drawn with probabilities p_k, an entry in a bibliography of n shares its key with another with probability Σ_k p_k (1 − (1 − p_k)^(n−1)). Common surnames make p_k large, so author-year keys collide often; adding a title word divides each p_k by the vocabulary’s spread.

Stale numbers. If a paper quotes N numbers m times each, every revision changes them all, and each hand update misses with probability p, then after r revisions the chance that some mention is stale is 1 − (1 − p)^(Nmr): with N = 40, m = 3, p = 0.005, it is 45% after one revision and 97% after six.

Line-by-line merging. With n lines and two authors each changing e distinct random lines, the chance they touch a common line is 1 − C(n − e, e)/C(n, e): 30% for 48 sentence lines and e = 4, far more when each line holds a whole paragraph.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With DOIs present in half of entries, a DOI match finds at most…
  2. 2. Author-year keys collide often because…
  3. 3. The chance of a stale number grows with revisions because…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How well do citation keys, DOIs, normalised titles and fuzzy title matching find duplicate entries in a bibliography assembled from different sources, and how often do they merge distinct papers?

History.

  • D. Knuth released TeX in 1978 to typeset The Art of Computer Programming; L. Lamport’s LaTeX macros (1984 to 1985) added document structure, and O. Patashnik and Lamport wrote BibTeX (1985).
  • B. Kernighan (1974) advised writers of text files to start each sentence on a new line, so edits stay local; the advice is now called semantic line breaks.
  • The DOI system, persistent identifiers for publications, was launched in 2000.
  • Overleaf began as WriteLaTeX (J. Hammersley and J. Lees-Miller, 2012) and merged with ShareLaTeX in 2017; most machine-learning venues require LaTeX templates, and arXiv keeps the LaTeX source of papers.

Exercise 2.

  • 5 bibliographies of 300 papers; 15% of papers are follow-ups of an earlier one (title with one word replaced, the same first author half the time, one to three years later).
  • Each paper has one entry, and a second with probability 0.3 (about 94 duplicates per bibliography). Entries come from one of two tools (author-year-word keys or DBLP-style keys), carry a DOI with probability 0.5, and are in title case, lower case or with a protected word. A duplicate may cite the arXiv version (a year earlier), and with probability 0.25 has a title revised by one word.
  • Precision and recall of the pairs of entries each rule merges.

Seed 0:

rule precision recall
same citation key 31.5% 26.1%
same DOI 100.0% 19.7%
same normalised title 99.5% 76.3%
fuzzy title (Jaccard ≥ 0.7), same first author, years within one 86.3% 99.8%

Seeds 1 and 2: keys 32.0% and 30.2% precision, 25.6% and 23.2% recall; DOIs 100% precision, 27.0% and 27.9% recall; normalised titles 98.0% and 99.4% precision, 75.2% and 76.0% recall; fuzzy 82.9% and 88.2% precision, 99.8% and 100% recall.

Findings.

  • Citation keys were useless for deduplication: they found about a quarter of duplicates and most pairs they merged were different papers, because tools write keys differently and DBLP-style keys collide.
  • DOI matches were always right but found only 20% to 28% of duplicates, near the 25% expected when each entry has a DOI half the time.
  • Normalised titles found about three quarters, missing exactly the duplicates whose titles had been revised.
  • Fuzzy matching found nearly every duplicate but 12% to 17% of its merges joined a paper with its follow-up: fuzzy matches need checking by hand.
🐍 Exercise 2 (research): how well do citation keys, DOIs, normalised titles and fuzzy title matching find duplicate entries in a bibliography assembled from different sources, and how often do they merge distinct papers?
Simulate bibliographies with duplicate entries and follow-up papers and compare four rules for finding duplicates by precision and recall.

LaTeX in practice

  • Keep the paper in version control (Overleaf’s git integration or a repository); one sentence per line.
  • Generate tables and numbers with a script that writes .tex files and macros from the results; regenerate before every submission.
  • Format tables with booktabs: no vertical rules, aligned decimals, bold only meaningful differences, and state what ± means.
  • Curate the bibliography: export from one source (DBLP or the publisher), prefer published versions over arXiv when they exist, add DOIs, protect capitals, and check fuzzy duplicates by hand.
  • Compile cleanly: fix every undefined reference and overfull box warning before the deadline, and check the venue’s template rules.

References

  1. D. E. Knuth (1984). The TeXbook. Addison-Wesley.
  2. L. Lamport (1994). LaTeX: A Document Preparation System, second edition. Addison-Wesley.
  3. O. Patashnik (1988). BibTeXing. Documentation distributed with BibTeX.
  4. B. W. Kernighan (1974). “UNIX for beginners.” Bell Laboratories.
  5. S. Fear. “Publication quality tables in LaTeX.” Documentation of the booktabs package.