Quarto HTML输出中替换图题冒号为句号的技术问询
Solution to Replace Figure Caption Colon with Period in Quarto HTML
Method 1: Use Quarto's Built-in Metadata Setting
- Add the
caption-label-separatoroption to your document's YAML metadata to globally adjust the separator for all figures, tables, and other captioned elements:
--- title: "Your Document Title" format: html caption-label-separator: "." ---
- This directly modifies how Quarto generates caption labels, replacing the default colon with a period.
Method 2: Lua Filter for Targeted Control
If the metadata setting doesn't work (e.g., for older Quarto versions), create a Lua filter file (e.g., caption-sep.lua) with the following code to rewrite caption text:
function Figure(el) if el.caption and el.caption[1] then el.caption[1].text = el.caption[1].text:gsub("(Figure %d+):", "%1.") end return el end function Table(el) if el.caption and el.caption[1] then el.caption[1].text = el.caption[1].text:gsub("(Table %d+):", "%1.") end return el end
- Reference the filter in your document's YAML to apply the change:
--- title: "Your Document Title" format: html filters: - caption-sep.lua ---
Why CSS Didn't Work
The default "Figure X:" is part of the raw caption text generated by Quarto, not a stylistic addition via CSS. Custom CSS can only modify visual styles, not the actual text content, so it can't replace the colon with a period.
内容的提问来源于stack exchange,提问作者Eric Krantz
相关产品推荐
相关产品推荐

