使用四开纸更改Word中的页面方向?

edv*_*syk 7 r pandoc quarto

使用 Quarto 并渲染为 Word 时,是否可以更改文档特定部分的页面方向?

理想的方法类似于 中的 BLOCK_LANDSCAPE_START/BLOCK_LANDSCAPE_STOP officedown

但也对其他方法感兴趣(例如使用参考文档)。

tar*_*leb 7

目前还没有统一的解决方案,但您可以通过使用自定义Lua 过滤器来解决。将下面给出的过滤器存储到一个文件中,例如docx-landscape.lua,然后通过filters在文档的 YAML 部分中列出它来使用它。使用带有横向类的围栏 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.
Run Code Online (Sandbox Code Playgroud)

其中过滤器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
Run Code Online (Sandbox Code Playgroud)

该过滤器需要一些快捷方式,但在大多数情况下应该可以正常工作。如果有任何问题,请告诉我。


附录:如果您更喜欢 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
end
Run Code Online (Sandbox Code Playgroud)