Table Formatting Fix Plan
Current Problems
HTML Output
- Caption font size not smaller (CSS
font-size: 0.85emnot applying) - First data row is incorrectly bold (
.table tbody tr:first-child tdrule) - Title and source combined in single caption line
- Caption appears at bottom but styling incomplete
Word Output
- Caption appears at TOP instead of bottom (despite
tbl-cap-location: bottom) - Caption in italics (Word default)
- Title and source combined
- No table numbering (acceptable per user)
Root Causes Identified
- Quarto bug #8970: Adding
{#tbl-label}breaks Word alignment - CSS specificity: Bootstrap/Quarto styles may override our caption styling
- Pandoc limitation:
tbl-cap-locationmay not work without cross-references - Wrong CSS rule:
.table tbody tr:first-child tdmakes first data row bold
Desired Styling (Bloomberg-Inspired Professional Financial Tables)
HTML Styling
| Element | Style |
|---|---|
| Table title | Bold, prominent, ~1.0-1.1em, same color as text, above table |
| Column headers | Bold (font-weight: 700), smaller than title (~0.85-0.9em) |
| Header row border | Solid 2px line below headers |
| Data cells | Smaller font (~0.85em), dense padding (0.3-0.4em) |
| First column (labels) | Left-justified |
| Numeric columns | Right-justified |
| Row separators | Subtle dotted lines in faint color (rgba(128,128,128,0.4)) |
| Last row | No bottom border |
| Source/caption | Below table, smaller font (~0.85em), left-justified, matches figure caption style |
Word Styling
| Element | Style |
|---|---|
| Table title | Bold, prominent, above table or as caption |
| Column headers | Bold |
| Header row border | Solid line below headers |
| Data cells | Normal font weight |
| First column (labels) | Left-justified |
| Numeric columns | Right-justified or centered |
| Row separators | None needed (clean look) |
| Source/caption | Below table, smaller font, left-justified, NOT italic |
Key Principles (Both Formats)
- Dense, compact presentation (financial/Bloomberg style)
- Clear visual hierarchy: Title > Headers > Data > Source
- Labels left-aligned, numbers right-aligned
- No table numbering (e.g., “Table 1:”) required
- Source attribution appears below table, not as prominent as title
Research Tasks
Task 1: Understand Quarto/Pandoc table caption handling
Task 2: Find alternative table structure
Task 3: Fix CSS issues
Task 4: Fix Word output
Proposed Solution
Option A: Separate Title and Source (Recommended)
Use this markdown structure:
**Performance Summary**
| Metric | FY2022-23 | FY2023-24 |
|:-------|----------:|----------:|
| Data | 123 | 456 |
*Source: Clean Energy Regulator*- Title: Bold paragraph above table
- Table: Standard markdown with alignment markers
- Source: Italic paragraph below table (not a caption)
Pros: - No cross-reference, so Word alignment works - Full control over styling - Works consistently in HTML and Word
Cons: - Not a “proper” table caption semantically - No automatic table numbering
Option B: Custom Quarto Extension/Filter
Create a Lua filter to handle table captions separately for HTML and Word.
Pros: - Proper semantic structure - Could fix the Quarto bug locally
Cons: - More complex to implement and maintain
Option C: Two Separate Output Pipelines
- HTML: Use
{#tbl-label}for proper captions - Word: Remove labels before rendering
Cons: - Maintenance burden
Test Plan
Test 1: Option A - Separate Title and Source
- Create test table with structure:
- Bold title paragraph
- Markdown table with alignment markers
- Italic source paragraph
- Render to HTML - verify styling
- Render to Word - verify alignment and appearance
Test 2: CSS Fixes
- Remove
.table tbody tr:first-child tdbold rule - Add more specific caption selectors
- Verify caption styling in HTML
Test 3: Word Caption Position
- Test if source as regular paragraph appears correctly
- Check alignment is preserved
Implementation Steps
- Fix CSS (remove incorrect bold rule, improve caption selectors)
- Modify one table to use Option A structure
- Render and test both outputs
- If successful, apply to all tables
- Update CLAUDE.md with new table formatting guidelines
Files to Modify
styles.css- Fix CSS rulesposts/safeguards review.md- Update table structure_quarto.yml- May need to adjust settingsCLAUDE.md- Document the solution for future use