在使用Quarto并将文档呈现为Word时,是否有一种方法可以更改文档特定部分的页面方向?
理想的方法应该是类似于officedown中的BLOCK_ something _START/BLOCK_ approach _STOP。
但也对其他方法感兴趣(例如使用引用-doc)。
发布于 2022-09-20 13:51:59
目前还没有统一的解决方案,但是您可以通过使用自定义Lua滤波器来解决问题。将下面提供给一个文件的过滤器存储起来,比如docx-landscape.lua,然后在文档的YAML部分中将它列在filters下面使用它。使用带类景观的有围栏的div标记应该出现在景观模式中的内容。
例如:
---
title: "Nullus"
filters:
- docx-landscape.lua
---
This is in portrait mode.
::: landscape
This should appear in landscape mode.
:::
Things should be back to normal here.过滤器docx-landscape.lua包含的
local ooxml = function (s)
return pandoc.RawBlock('openxml', s)
end
local end_portrait_section = ooxml
'<w:p><w:pPr><w:sectPr></w:sectPr></w:pPr></w:p>'
local end_landscape_section = ooxml [[
<w:p>
<w:pPr>
<w:sectPr>
<w:pgSz w:h="11906" w:w="16838" w:orient="landscape" />
</w:sectPr>
</w:pPr>
</w:p>
]]
function Div (div)
if div.classes:includes 'landscape' then
div.content:insert(1, end_portrait_section)
div.content:insert(end_landscape_section)
return div
end
end过滤器需要一些捷径,但在大多数情况下应该可以正常工作。请告诉我关于它的任何问题。
增编:如果您更喜欢officedown命令,那么将以下内容添加到筛选器中,以使这些命令工作:
function RawBlock (raw)
if raw.text:match 'BLOCK_LANDSCAPE_START' then
return end_portrait_section
elseif raw.text:match 'BLOCK_LANDSCAPE_STOP' then
return end_landscape_section
end
endhttps://stackoverflow.com/questions/73784720
复制相似问题