2

I've been trying to work out if it's possible to format the "horizontal rule" (as Quarto visual editor calls it) or --- in markdown, when outputting from Quarto .qmd to .docx. The default is thick pale grey line, and I'd like a thin black line if possible.

I've tried editing the outputted line within a style on the reference-doc, but that doesn't work.

Quinten
  • 35,235
  • 5
  • 20
  • 53
ttalVlatt
  • 138
  • 6

2 Answers2

1

You could use css style to change the background color of the horizontal rule line when using --- in your document. Create separate css file called styles.css. Here is some reproducible code:

---
title: "Untitled"
format: 
  html:
    css: styles.css
---

## Quarto

Here is the horizontale rule line in black

---

Output:

enter image description here

styles.css file:

hr {
    height: 3px;
    background-color: #0000000;
}
Quinten
  • 35,235
  • 5
  • 20
  • 53
  • Hmm, this didn't work for me, I'm looking for it to change in the .docx output not the html. It's not a big deal, I just was wondering if it's possible (other than going into the final .docx and changing it by hand) – ttalVlatt Jun 18 '23 at 11:34
0

For anyone interested, I figured out a way to edit the .docx output horizontal rule in Quarto. I wrote a quick lua filter based on the some of the code here and set it up to work in Quarto.

The raw code of the lua filter is here

-- Converts default grey horiztonal rule to thin black line (customizable in line 10)
-- h/t https://github.com/jgm/pandoc/issues/2573
-- h/t https://gist.github.com/Merovex/05e3216f8f4f6e965cd9d564b1496719
local horizontallinerule = [[<w:p>
  <w:pPr>
    <w:pStyle w:val="HorizontalRule"/>
      <w:ind w:firstLine="0"/>
      <w:jc w:val="center"/>
    <w:pBdr>
      <w:bottom w:val="single" w:color="000000"/>
    </w:pBdr>
  </w:pPr>
  <w:r>
    <w:t></w:t>
  </w:r>
</w:p>]]
function HorizontalRule (elem)
    if FORMAT == 'docx' then
      return pandoc.RawBlock('openxml', horizontallinerule)
    end
end

I also set it up to work in the _extensions file in a Quarto doc here

ttalVlatt
  • 138
  • 6