Marp tables: syntax, alignment, size, centring, contents
Marp renders GitHub-flavoured pipe tables: a header row, a separator row whose colons set alignment (:-- left, :-: centre, --: right), then the rows. The theme sets the size (section table { font-size: 18px; }); a table wider than the slide is cut off, not shrunk, so a wide table becomes two slides or a figure. A table of contents is a slide you write, since Marp has no directive for one.
This guide covers the syntax, alignment, size and style, centring, wide tables, and the agenda slide that "table of contents" searches are usually after.
Syntax
| Policy | Waiting | Response | Starvation |
|:-------|--------:|---------:|:----------:|
| FCFS | high | poor | no |
| SJF | lowest | poor | yes |
| RR | medium | good | no |
Colons on the separator row set the alignment per column; the output carries text-align on each cell, so it survives every export. Inline Markdown works inside cells (**bold**, `code`, links); block content (lists, paragraphs) does not, which is the limit that pushes a comparison into a two-column layout instead.
Size and style
Tables inherit the base font, which is too large for real data. In the theme or the front matter:
section table { font-size: 18px; }
section th { font-weight: 600; background: #f5f5f5; }
section td, section th { padding: 4px 10px; border-bottom: 1px solid #e5e5e5; }
section tr:nth-child(even) td { background: #fafafa; }
The built-in themes draw light borders; the rules above are for a custom theme. Keep the header row visually distinct; on a projector a table with no header emphasis reads as a grid of noise.
Centring
A table sizes to its content and sits left. To centre it:
section table { margin-left: auto; margin-right: auto; }
For full width, section table { width: 100%; }. Choose one per theme.
Too wide
Marp cuts off what does not fit; the Check slides scan in Lecture Studio and the overflow warning in the VS Code extension find it. Then:
- Show the columns that carry the claim, and put the full table in the handout.
- Split into two tables on two slides with the same first column.
- Shrink with
<style scoped>section table { font-size: 14px; }</style>only if the back row can still read 14 px. - Turn a numeric table into a chart, as an image.
A table with more than five columns or eight rows is a document, not a slide.
The contents slide
Marp has no table-of-contents directive. An agenda slide is a numbered list you maintain, which is fine for a deck of forty slides with four sections:
## Today
1. Why scheduling is a trade-off
2. FCFS and SJF by hand
3. Round-robin and the quantum
4. Where each one wins
If the deck is exported to HTML, the entries can link to slides by number ([Round-robin](#5) jumps to slide 5 in the bespoke template). For a PDF, marp --pdf-outlines adds a bookmark tree from the headings, which is the contents students actually use.
Data from a file
Tables in slides are typed. For a table that changes every term, keep the data in a CSV and generate the Markdown rows with a few lines of script, or paste from a spreadsheet through any Markdown table converter; the pipes are simple enough that a spreadsheet export with | separators is nearly there.
FAQ
How do I make a table in Marp?
GitHub-flavoured pipe syntax: a header row, a separator row, then data rows. Colons on the separator set alignment.
How do I make a Marp table smaller?
section table { font-size: 18px; } in the theme or style: block; <style scoped> for one slide. If it still overflows, show fewer columns.
How do I center a table in Marp?
section table { margin-left: auto; margin-right: auto; }.
Does Marp have a table of contents?
No directive. Write an agenda slide by hand; for PDFs, --pdf-outlines adds bookmarks from the headings.