【发布时间】:2018-11-16 11:32:42
【问题描述】:
如何在 R 中使用官员更改标题的字体系列?我正在尝试使用函数fp_text(font.family = "Arial"),但问题是我使用fp_text 定义的标题并没有出现在目录中。
【问题讨论】:
如何在 R 中使用官员更改标题的字体系列?我正在尝试使用函数fp_text(font.family = "Arial"),但问题是我使用fp_text 定义的标题并没有出现在目录中。
【问题讨论】:
这有点痛苦,但我这样做的方式是:
ph_empty()
ph_add_fpar() 添加格式化文本,使用fpar()、ftext() 和fp_text() 创建格式化文本对象。以下是如何更改标题幻灯片以及标题和内容幻灯片上的标题的示例,假设您要使用的字体是“Rage Italic”和“Goudy Stout”:
library(officer)
library(magrittr)
# the formatting you want to use goes here -- check your fonts()
format_main_title <- fp_text(font.family='Rage Italic', font.size=72)
format_page_title <- fp_text(font.family='Goudy Stout', font.size=24)
read_pptx() %>%
add_slide(layout = 'Title Slide', master='Office Theme') %>%
ph_empty(type='ctrTitle') %>%
ph_add_fpar(fpar(ftext('Fancy Main Title', prop=format_main_title)),
type = 'ctrTitle') %>%
add_slide(layout = 'Title and Content', master='Office Theme') %>%
ph_empty(type='title') %>%
ph_add_fpar(fpar(ftext('Fancy Page Title', prop=format_page_title)),
type = 'title') %>%
ph_with_text(type = 'body', str = 'Boring stuff goes here') %>%
print('test.pptx')
产生:
您可以在目录中看到这些标题:
话虽如此 - 如果您发现自己不断将标题字体更改为相同的新格式,您最好使用您自己的幻灯片母版(而不是默认的“Office 主题”)创建一个模板组,该模板使用您想要的字体并以此开始您的连锁店(即read_pptx('your_template.pptx') %>% etc.)
【讨论】:
Error: selection does not match any row in slide_summary. Use function slide_summary.。