问题描述
具有输出格式 beamer
的R markdown演示文稿可以使用
- 经典的LaTex投影仪主题 ,例如哥本哈根或马德里,或使用自定义的投影仪主题.
- 模板,即
template.tex
- 包含,例如
in_header:preamble.tex
,before_body:before_body.tex
和after_body:after_body.tex
可以通过YAML标头在 rmarkdown :: beamer_presentation
中实现,如下所示:
主题:"THEMENAME";模板:template.tex包括:in_header:preamble.texbefore_body:before_body.texafter_body:after_body.tex
问题一: 上面列出的这些文件的具体用途是什么?
我为放映机提供了一个自定义主题,其中包含 beamerthemeTHEMENAME.sty ,
beamercolorthemeTHEMENAME.sty ,
beamerfontthemeTHEMENAME.sty ,
beamerinnerthemeTHEMENAME.sty
, beamerouterthemeTHEMENAME.sty
.在我的YAML标头中提供此模板并不会导致该演示文稿看起来与使用LaTex直接生成并应用自定义主题的任何投影仪演示文稿都过于接近.
例如,在 beamerouterthemeTHEMENAME.sty
中,定义了一个新的 titleframe
,然后可以在LaTex演示文稿的开头使用 \来调用它.标题框架
.我没有在 rmarkdown :: beamer_presentation
中应用此自定义框架类型.
问题II: 在 rmarkdown :: beamer_presentation
中应用 LaTex Beamer主题
,该内容用于修改或增强演示文稿
- 必须进行修改或
- 从移至
template.tex
和includes
,是否可以像在LaTex中一样将它们应用于rmarkdown中的演示文稿?
问题III: 自定义 theme
, template.tex
和的最终文件是否可以包含
移到用于显示文件夹整洁的子文件夹中,并且仍然可以正确加载
MWE&剩余的问题
- 不能使用在
beamerouterthemeTHEMENAME.sty
中定义的以下框架模板:\ titleframe
,\ tocframe
,\ closingframe 代码>
在 - 脚线:
- 成功将页码链接到
附录
. - 很高兴将徽标链接到
目录
幻灯片
- 成功将页码链接到
beamerouterthemeTHEMENAME.sty
中定义的MWE.Rmd
---标题:"MWE"副标题:具有R-markdown的光束预视"研究所:某处"日期:`r format(Sys.time(),'%B%d,%Y')`";输出:#beamer_presentation:默认bookdown :: pdf_book:base_format:rmarkdown :: beamer_presentation#包括:#in_header:preamble.tex主题:"THEMENAME";latex_engine:xelatex目录:假slide_level:2---``{r setup,include = FALSE}knitr :: opts_chunk $ set(echo = FALSE)```# 随机呈现## TOC-目录{.unnumbered}\目录\ label {内容}##带子弹滑-子弹1-第2弹-子弹3##附录\附录
beamerthemeTHEMENAME.sty
\ usepackage [utf8] {inputenc}%Tizk,textpos,图形\ RequirePackage {tikz}\ RequirePackage {textpos}\ RequirePackage {xcolor}\RequirePackage{booktabs}投影机设置百分比\ usecolortheme {THEMENAME}\ useoutertheme {THEMENAME}\ setbeamertemplate {导航符号} {}\ mode< all>
beamercolorthemeTHEMENAME.sty
\ mode< presentation>\ definecolor {THEMECOL} {RGB} {162,48,47}红色\ definecolor {THEMEgray} {RGB} {110,110,101}%灰色\ colorlet {titlefgcolor} {THEMECOL}盒子的颜色\ colorlet {titlebgcolor} {THEMEgray}包装盒颜色%\ setbeamercolor * {title} {fg = THEMECOL}%演讲标题\ setbeamercolor * {author} {fg = THEMECOL}%作者\ setbeamercolor * {date} {fg = THEMECOL}%日期\ mode< all>
beamerouterthemeTHEMENAME.sty
\ mode< presentation>%重新定义\ insertshortinstitute以允许多行\ makeatletter\ renewcommand {\ insertshortinstitute} {\ beamer @ shortinstitute}\ makeatother%标题框\ def \ titlefigure {img/my_bg}\ newlength \ titleboxwidth\ setlength {\ titleboxwidth} {0.33 \ textwidth}\ newcommand {\ titleframe} {%{\setbeamertemplate{背景}{\ begin {tikzpicture}\useasboundingbox (0,0) 矩形(\the\paperwidth,\the\paperheight);\ ifx \ titlefigure \ empty\ fill [titlebgcolor](6.3mm,6.4mm)矩形(\ the \ paperwidth-8.3mm,\ the \ paperheight-13mm);\别的\ node在(当前page.center)处[anchor = center,yshift = -3.5mm] {\ includegraphics [width = \ the \ paperwidth-19mm] {\ titlefigure}};\ fi\ node位于(当前页面.东北)[锚点=东边,xshift = -8.3mm,yshift = -6.3mm,align = left,内部sep = 0mm,font = \ fontsize {5.5} {6.6} \ selectfont]{\ insertshortinstitute};\ node位于(当前页.西北)[anchor =西南,内部sep = 0mm,xshift = 8.3mm,yshift = -8.6mm] {\ includegraphics [高度= 3.8毫米] {img/my_logo}};\ end {tikzpicture}}\ setbeamertemplate {footline} {}\ begin {frame} [noframenumbering]\ begin {tikzpicture}\useasboundingbox (0,0) 矩形(\the\paperwidth,\the\paperheight);\ node [shift = {(-11.5mm,-1.8mm)},fill = titlefgcolor,最小宽度= 0.46 \ paperwidth,最小高度= 18mm,锚=西,内部隔垫= 4mm],位于(当前page.west){\ hspace * {9mm}\ begin {minipage} {\ titleboxwidth}\ rackright\ usebeamerfont {title} \ usebeamercolor [fg] {title} \ inserttitle \\ [3mm]\ usebeamerfont {author} \ usebeamercolor [fg] {author} \ insertauthor \\\ usebeamerfont {date} \ usebeamercolor [fg] {date} \ insertdate\ end {minipage}};\ end {tikzpicture}\ end {frame}}}%TOC帧\ newcommand {\ tocframe} {%\ begin {frame}\ frametitle {概述}\目录\ end {frame}}%部分标题框架\ AtBeginSection []{\ begin {frame}\ frametitle {概述}\大\ tableofcontents [currentsection]\ end {frame}}\ newenvironment {closingframe} {\setbeamertemplate{背景}{\ begin {tikzpicture}\useasboundingbox (0,0) 矩形(\the\paperwidth,\the\paperheight);\ node位于(当前页.西北)[锚点=基准西,xshift = 8mm,yshift = -10mm,align = left] {\ includegraphics [width = 23mm] {img/my_logo.png}};\ end {tikzpicture}}\ setbeamertemplate {footline} {}\ addtolength {\ headsep} {10mm}\ begin {frame} [noframenumbering]}%{\ end {frame}}%足迹百分比\ setbeamertemplate {footline} {\ leavevmode%\ hyperlink {contents} {\ includegraphics [width = 12mm,trim = 0mm 0.4mm 0mm 0mm] {img/my_logo.png}}\ hfill\hyperlinkappendixstart{\insertframenumber/\inserttotalframenumber}\ vspace {3mm}}\ mode< all>
@ Samcarter_is_at_topanswers.xyz是正确的.这是一个广泛的问题.
最简单的回答是,您可以使用 beamercolor ... sty
和关联的文件来创建自定义的投影机卡座.我将RStudio用作 R
IDE,并编写了"plugin"这样您就可以生成新的自定义投影仪演示文稿,就像生成其他任何新文档一样:即File->新文件->R Markdown->从模板
我将 .sty
文件保存在我称为 customtex
之类的主目录中,并带有 tex
目录和 beamer
目录.
-companytex-特克斯-投影仪[房子`.sty`文件]- 乳胶
当我在RStudio中使用 From Template
时,这些文件将与创建的新 .Rmd
文件一起复制到我确定的特定位置.
-reportdir-.md文件-图目录-资源目录-图像目录-主题目录-用于生成投影仪的所有我的.sty文件
当我单击 Knit
(或以其他方式运行 render()
)时,自定义的 .sty
文件将用作模板./p>
R markdown presentations with output format beamer
can make use of
- Classical LaTex beamer themes such as Copenhagen or Madrid or employ custom beamer themes.
- Templates , i.e. a
template.tex
- Includes, e.g.
in_header: preamble.tex
,before_body: before_body.tex
andafter_body: after_body.tex
which can be implemented in the rmarkdown::beamer_presentation
through the YAML-header as follows:
theme: "THEMENAME"
template: template.tex
includes:
in_header: preamble.tex
before_body: before_body.tex
after_body: after_body.tex
Question I: What are the specific purposes of these files listed above?
I got provided with a custom themes for beamer, containing beamerthemeTHEMENAME.sty
, beamercolorthemeTHEMENAME.sty
, beamerfontthemeTHEMENAME.sty
, beamerinnerthemeTHEMENAME.sty
, beamerouterthemeTHEMENAME.sty
.Sourcing this template within my YAML header does not lead to the presentation looking too close to any beamer presentation generated straight with LaTex and applying the custom theme.
As an example, in the beamerouterthemeTHEMENAME.sty
, a new titleframe
is defined, which can then be called at the beginning of the LaTex presentation with \titleframe
.I did not succeed in applying this custom frame-type in the rmarkdown::beamer_presentation
.
Question II: Applying a LaTex beamer theme
in an rmarkdown::beamer_presentation
, which contents to modify or enhance the presentation
- would have to be adapted or
- moved from the
beamer theme
totemplate.tex
andincludes
such that they are applied to the presentation in rmarkdown just as in LaTex?
Question III: Can the final files of the custom theme
, the template.tex
, and the includes
be moved to a sub-folder for the neater organization of the presentation folder and still be loaded correctly
MWE & issues remaining
- Can not use the following frame templates defined in
beamerouterthemeTHEMENAME.sty
:\titleframe
,\tocframe
,\closingframe
- footline defined in
beamerouterthemeTHEMENAME.sty
:- Succeeded in linking the page numbers to the
appendix
. - Would be nice to link the logo to the
table of contents
slide
- Succeeded in linking the page numbers to the
MWE.Rmd
---
title: "MWE"
subtitle: "Beamer presnetation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
# beamer_presentation: default
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
# includes:
# in_header: preamble.tex
theme: "THEMENAME"
latex_engine: xelatex
toc: false
slide_level: 2
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Random presentation
## TOC - Table of Contents {.unnumbered}
\tableofcontents
\label{contents}
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Apendix
\appendix
beamerthemeTHEMENAME.sty
\usepackage[utf8]{inputenc}
% Tizk, textpos, graphics
\RequirePackage{tikz}
\RequirePackage{textpos}
\RequirePackage{xcolor}
\RequirePackage{booktabs}
% Beamer settings
\usecolortheme{THEMENAME}
\useoutertheme{THEMENAME}
\setbeamertemplate{navigation symbols}{}
\mode<all>
beamercolorthemeTHEMENAME.sty
\mode<presentation>
\definecolor{THEMECOL}{RGB}{162,48,47} % red
\definecolor{THEMEgray}{RGB}{110,110,101}% gray
\colorlet{titlefgcolor}{THEMECOL} % color of box
\colorlet{titlebgcolor}{THEMEgray} % color of box
\setbeamercolor*{title}{fg=THEMECOL} % presentation title
\setbeamercolor*{author}{fg=THEMECOL} % author
\setbeamercolor*{date}{fg=THEMECOL} % date
\mode<all>
beamerouterthemeTHEMENAME.sty
\mode<presentation>
% Redefine \insertshortinstitute to allow multiple lines
\makeatletter
\renewcommand{\insertshortinstitute}{\beamer@shortinstitute}
\makeatother
% Title frame
\def\titlefigure{img/my_bg}
\newlength\titleboxwidth
\setlength{\titleboxwidth}{0.33\textwidth}
\newcommand{\titleframe}{%
{
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\ifx\titlefigure\empty
\fill[titlebgcolor] (6.3mm,6.4mm) rectangle (\the\paperwidth-8.3mm,\the\paperheight-13mm);
\else
\node at (current page.center) [anchor=center,yshift=-3.5mm] {\includegraphics[width=\the\paperwidth-19mm]{\titlefigure}};
\fi
\node at (current page.north east) [anchor=base east, xshift=-8.3mm, yshift=-6.3mm, align=left, inner sep=0mm, font=\fontsize{5.5}{6.6}\selectfont] {
\insertshortinstitute
};
\node at (current page.north west) [anchor=south west, inner sep=0mm, xshift=8.3mm, yshift=-8.6mm] {
\includegraphics[height=3.8mm]{img/my_logo}
};
\end{tikzpicture}
}
\setbeamertemplate{footline}{}
\begin{frame}[noframenumbering]
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\node [
shift={(-11.5mm,-1.8mm)},
fill=titlefgcolor,
minimum width=0.46\paperwidth,
minimum height=18mm,
anchor=west,
inner sep=4mm
] at (current page.west) {
\hspace*{9mm}
\begin{minipage}{\titleboxwidth}
\raggedright
\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\\[3mm]
\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\\
\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
\end{minipage}
};
\end{tikzpicture}
\end{frame}
}
}
% TOC frame
\newcommand{\tocframe}{%
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
}
% Section title frame
\AtBeginSection[]
{
\begin{frame}
\frametitle{Outline}
\large
\tableofcontents[currentsection]
\end{frame}
}
\newenvironment{closingframe}{
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\node at (current page.north west) [anchor=base west, xshift=8mm, yshift=-10mm, align=left] {
\includegraphics[width=23mm]{img/my_logo.png}
};
\end{tikzpicture}
}
\setbeamertemplate{footline}{}
\addtolength{\headsep}{10mm}
\begin{frame}[noframenumbering]
}%
{
\end{frame}
}%
% Footline
\setbeamertemplate{footline}{
\leavevmode%
\hyperlink{contents}{\includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{img/my_logo.png}}
\hfill
\hyperlinkappendixstart{\insertframenumber/\inserttotalframenumber}
\vspace{3mm}
}
\mode<all>
@Samcarter_is_at_topanswers.xyz is right. This is a broad question.
The simplest response is yes, you can use the beamercolor...sty
and associated files to create your custom beamer deck. I use RStudio as my R
IDE and I wrote a "plugin" that allows me to generate a new custom beamer presentation just like you would generate any other new doc: i.e., File -> New file -> R Markdown -> From Template
I keep the .sty
files in home directory I call customtex
or something, with a tex
directory and a beamer
dir.
- companytex
- tex
- beamer [houses `.sty` files]
- latex
When I use From Template
in RStudio, these files get copied into the specific location I determine, along with the new .Rmd
file that is created.
- reportdir
- .Rmd file
- figure dir
- resources dir
- images dir
- theme dir
- all of my `.sty` files for beamer generation
When I click the Knit
(or otherwise run render()
), the custom .sty
files are used as the template.
这篇关于如何使用自定义的投影仪主题,模板以及包含在使用R markdown生成的投影仪演示文稿中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!