【问题标题】:Change Title/Headings Font in Quarto PDF Output更改四开本 PDF 输出中的标题/标题字体
【发布时间】:2022-11-18 20:16:44
【问题描述】:

当 RMarkdown .rmd 文档被编织为 PDF 时,正文以及标题、副标题和小标题都以相同的 LaTeX 标准字体呈现。

将 Quarto .qmd 文档呈现为 PDF 时,正文的字体保持不变,但标题、副标题和标题以不同的字体呈现,没有衬线。

为了使旧版 R Markdown 文档和新版 Quarto 文档的输出保持一致,我想将标题、副标题和标题的字体更改回正常字体。我怎样才能做到这一点?

我尝试在 YAML 标头中使用 fontfamily:,但这没有找到我想要的字体。通过在include-in-header: 中使用\setkomafont{section}{\normalfont},我取得了一些成功,因为这确实更改了字体,但仅适用于 h1 标题,不适用于 h2,也不适用于标题或副标题。它还删除了 h1 的所有其他格式(例如字体大小、粗体等),这不是我想要的。

【问题讨论】:

    标签: pdf latex quarto


    【解决方案1】:

    使用来自 Tex StackExchange 的this answer,我们可以轻松地在四开本中完成此操作。

    ---
    title: "Fonts"
    subtitle: "Changing fonts of title, subtitle back to normal font"
    author: "None"
    format:
      pdf:
        include-in-header:
          text: |
            ddtokomafont{disposition}{
    mfamily}
    ---
    
    ## Quarto
    
    Quarto enables you to weave together content and executable code into a 
    finished document. To learn more about Quarto see <https://quarto.org>.
    
    ## Running Code
    
    When you click the **Render** button a document will be generated that includes
    both content and the output of embedded code.
    


    当然,查看 KOMA-Script 手册的 section 3.6 - Text Markup,它提供了非常详细的元素列表(如 authorchaptertitlesubtitledate 等)这样的改变是可以做到的。

    【讨论】:

      【解决方案2】:

      如果正文中使用的字体已知,则可以使用sansfont: ... 设置标题和标题中使用的字体。明智的做法是同时设置mainfont 以确保它们相同。

      使用的默认字体是Latin Modern Roman,所以将它添加到 YAML frontmatter 应该可以做到:

      ---
      mainfont: Latin Modern Roman
      sansfont: Latin Modern Roman
      ---
      

      【讨论】:

        猜你喜欢
        • 2019-10-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-13
        • 2015-10-04
        • 2011-05-02
        • 2015-04-04
        • 2012-05-25
        相关资源
        最近更新 更多