【问题标题】:Is it possible to define a letterhead header in Rmarkdown?是否可以在 Rmarkdown 中定义信头标题?
【发布时间】:2018-07-19 14:52:58
【问题描述】:

R 大师,

我正在努力在 Rmarkdown 中为一个大型邮件合并项目设计一个信头模板。

理想情况下,我需要的是以下内容:

问题是是否可以在 YAML 中定义标头?代码可能如下所示:

---
output: 
  pdf_document:
    fig_caption: false

logo: logo.png
institute: UNIVERSITY OF CALIFORNIA
name: Prof. Jones
address: Mathematics Search Committee
         Department of Mathematics
         University of California
         Berkeley, California 12345
email: pj@uc.ac

latex_engine: pdflatex
fontfamily: mathpazo
fontsize: 11pt
# spacing: double
endnote: no
---

【问题讨论】:

  • 你见过pandoc-letter template吗?它可能正是您所需要的。
  • 我会复制默认模板(github.com/rstudio/rmarkdown/blob/master/inst/rmd/latex/…)并根据您的需要编辑头部。然后使用 YAML 选项 template 包含模板。
  • 文档的动态部分是什么?
  • 动态部分是用 Markdown 写的个性化信件,包含考试成绩等详细信息。
  • 我知道 CRAN 上有两个面向字母的包:linlkomaletter。它们似乎都不完全符合要求,但两者都可能是一个很好的起点。

标签: r latex knitr r-markdown pandoc


【解决方案1】:
---
title: "Prof. Jones  \nDepartment  \nUniversity  \nState  \nEmail"
output: pdf_document
editor_options: 
  chunk_output_type: console
header-includes:
  - \usepackage{titling}
  - \usepackage{graphicx} 
  - \usepackage{fancyhdr}
  - \pagestyle{fancy}
  - \pretitle{\begin{flushright}\LARGE\includegraphics[width=8cm]{logo.jpg}\\[\bigskipamount]}
  - \posttitle{\end{flushright}}
---

将您的徽标添加到具有{logo.jpg} 的位置,宽度可能也需要更改。

使用双倍空格和\n 在标题中添加换行符以创建地址的解决方法。

flushright 然后右对齐徽标和标题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多