首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Quarto改变word中的页面方向?

用Quarto改变word中的页面方向?
EN

Stack Overflow用户
提问于 2022-09-20 09:47:56
回答 1查看 176关注 0票数 4

在使用Quarto并将文档呈现为Word时,是否有一种方法可以更改文档特定部分的页面方向?

理想的方法应该是类似于officedown中的BLOCK_ something _START/BLOCK_ approach _STOP。

但也对其他方法感兴趣(例如使用引用-doc)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-20 13:51:59

目前还没有统一的解决方案,但是您可以通过使用自定义Lua滤波器来解决问题。将下面提供给一个文件的过滤器存储起来,比如docx-landscape.lua,然后在文档的YAML部分中将它列在filters下面使用它。使用带类景观的有围栏的div标记应该出现在景观模式中的内容。

例如:

代码语言:javascript
复制
---
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包含的

代码语言:javascript
复制
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命令,那么将以下内容添加到筛选器中,以使这些命令工作:

代码语言:javascript
复制
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
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73784720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档