英文:
Is there a way to format the "horizontal rule" (i.e., ---) output Quarto to .docx?
问题
我一直在尝试确定是否可以在从Quarto .qmd格式输出到.docx时格式化“水平线”(如Quarto视觉编辑器所称),或者在Markdown中使用---。默认情况下是粗的淡灰色线条,如果可能的话,我想要细的黑色线条。
我尝试在参考文档上编辑输出的线条样式,但这并不起作用。
英文:
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.
答案1
得分: 1
你可以使用 CSS 样式来更改文档中使用 ---
时水平规则线的背景颜色。创建一个名为 styles.css
的单独的 CSS 文件。以下是一些可重现的代码:
hr {
height: 3px;
background-color: #0000000;
}
输出:
英文:
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:
styles.css
file:
hr {
height: 3px;
background-color: #0000000;
}
答案2
得分: 0
以下是您要翻译的内容:
"对于任何感兴趣的人,我找到了一种在Quarto中编辑.docx输出水平线的方法。我基于此处的一些代码编写了一个快速的lua过滤器,并设置它在Quarto中工作。
lua过滤器的原始代码如下
-- 将默认的灰色水平线转换为细黑线(可在第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
我还将其设置为在Quarto文档的_extensions文件中工作 这里"
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论