【问题标题】:RMarkdown: Customize Color and Font Size of (automated) CitationsRMarkdown:自定义(自动)引文的颜色和字体大小
【发布时间】:2022-07-25 18:06:17
【问题描述】:

我对 RMarkdown 相当陌生,并试图在这里应用一些 LaTeX 逻辑。目前,我正在使用 RMarkdown (beamer_presentation) 创建一个 PDF 演示文稿。是否可以更改自动引用 ([@shortname]) 的字体大小和颜色,例如,所有引用看起来都比正常文本略小并且呈灰色? 在 LaTeX beamer 演示文稿中,我设法重新定义了 cite 命令并应用了它。但是,我还不能在 RMarkdown 中重新创建它。

当我尝试手动(我更喜欢自动解决方案)更改引用\textcolor{gray}{[e.g., @shortname]}(也为$\textcolor{gray}{[e.g., @shortname]}$)的字体颜色时,我收到了以下错误消息:

我无法从错误日志 slides.log 中找到任何丢失的 LaTeX 包。 !缺少插入的 $。 $ l.182 \end{frame} 尝试在 slides.Rmd 中找到以下文本: \end{frame} 您可能需要在 slides.Rmd 中的某个内联 R 表达式 r 周围添加 $ $(请参阅上面的提示)。请参阅https://github.com/rstudio/rmarkdown/issues/385 了解更多信息。

错误消息中的链接也没有帮助我。

感谢您的帮助!我将在下面包含一个 MWE。

直到

---
title: "A title"
author: "Till"
date: 25.07.2022
output:
  beamer_presentation:
    incremental: true # bullet points on multiple pages
    toc: false # add generated page listing sections
    slide_level: 2 # depth level for render content
    latex_engine: lualatex 
    keep_tex: TRUE
bibliography: literature.bib
csl: american-sociological-association.csl
header-includes:  \usepackage{xcolor} 
---

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = TRUE)
options(tinytex.verbose = TRUE) #  for debugging
```

# First Section

## Example Slide

- Some text which will be followed by a citation \textcolor{gray}{[e.g., @shortname]}
- Some more text, now without a citation 

literature.bib 文件可能看起来像这样:

@article{shortname,
    title = {citation title},
    journaltitle = {Journal},
    shortjournal = {Journal},
    author = {Lastname, Firstname},
    date = {2022},
}

【问题讨论】:

    标签: r r-markdown markdown beamer


    【解决方案1】:

    \textcolor 方法的问题是您不能在乳胶宏的参数中使用降价语法。你可以通过\begingroup \color{gray} [e.g., @shortname] \endgroup来避免这个问题:

    ---
    title: "A title"
    author: "Till"
    date: 25.07.2022
    output:
      beamer_presentation:
        incremental: true # bullet points on multiple pages
        toc: false # add generated page listing sections
        slide_level: 2 # depth level for render content
        latex_engine: lualatex 
        keep_tex: TRUE
    bibliography: literature.bib
    csl: american-sociological-association.csl
    header-includes:  \usepackage{xcolor} 
    ---
    
    #```{r setup, include=FALSE} 
    # I did not know how to include R-Chunks in the code block withouth breaking the formatting, so just remove the Hashtags before the three ticks and this endless comment
    knitr::opts_chunk$set(echo = TRUE)
    options(tinytex.verbose = TRUE) #  for debugging
    #```
    
    # First Section
    
    ## Example Slide
    
    - Some text which will be followed by a citation \begingroup \color{gray} [e.g., @shortname] \endgroup
    - Some more text, now without a citation 
    

    【讨论】:

      猜你喜欢
      • 2014-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      相关资源
      最近更新 更多