【问题标题】:Adding a footnote in rmarkdown header在 rmarkdown 标头中添加脚注
【发布时间】:2020-06-22 12:24:34
【问题描述】:

我在 YAML 标头中添加脚注时遇到了一些问题。如果标题中没有该脚注,则编织执行效果很好。但是,在文档的不同部分添加脚注不会导致错误。

非常感谢任何建议。

---
title: "Document1"
author: "Test^[this is a test]"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: pdf_document
latex_engine: xelatex    
---

错误:

! Argument of \reserved@a has an extra }.
<inserted text> 
                \par 
l.76 \author{Test\footnote{this is a test}}

sessionInfo()

R version 4.0.1 (2020-06-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.7.9 zoo_1.8-8       magrittr_1.5    knitr_1.28      forcats_0.5.0  
 [6] stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4     readr_1.3.1     tidyr_1.1.0    
[11] tibble_3.0.1    ggplot2_3.3.2   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] tinytex_0.24     tidyselect_1.1.0 xfun_0.14        haven_2.3.1     
 [5] lattice_0.20-41  colorspace_1.4-1 vctrs_0.3.1      generics_0.0.2  
 [9] htmltools_0.5.0  yaml_2.2.1       utf8_1.1.4       blob_1.2.1      
[13] rlang_0.4.6      pillar_1.4.4     glue_1.4.1       withr_2.2.0     
[17] DBI_1.1.0        dbplyr_1.4.4     modelr_0.1.8     readxl_1.3.1    
[21] lifecycle_0.2.0  munsell_0.5.0    gtable_0.3.0     cellranger_1.1.0
[25] rvest_0.3.5      evaluate_0.14    fansi_0.4.1      highr_0.8       
[29] broom_0.5.6      Rcpp_1.0.4.6     backports_1.1.7  scales_1.1.1    
[33] jsonlite_1.6.1   fs_1.4.1         hms_0.5.3        digest_0.6.25   
[37] stringi_1.4.6    grid_4.0.1       cli_2.0.2        tools_4.0.1     
[41] crayon_1.3.4     pkgconfig_2.0.3  ellipsis_0.3.1   xml2_1.3.2      
[45] reprex_0.3.0     assertthat_0.2.1 rmarkdown_2.3.1  httr_1.4.1      
[49] rstudioapi_0.11  R6_2.4.1         nlme_3.1-148     compiler_4.0.1

【问题讨论】:

    标签: r r-markdown markdown


    【解决方案1】:

    如果您尝试 rmarkdown::render('~/test_.rmd', encoding = 'UTF-8') 会发生这种情况吗?什么是sessionInfo() 结果?

    【讨论】:

    • 添加了会话信息详细信息,执行了命令,但同样的问题。还是谢谢你。
    【解决方案2】:

    你可以这样做:

    ---
    title: "Document1"
    author: "Test[^note]"
    date: "`r format(Sys.time(), '%d %B, %Y')`"
    output: pdf_document
    latex_engine: xelatex    
    ---
    
    [^note]: this is a test
    
    

    一般来说,pandoc markdown 中的脚注是这样定义的:

    这是一个脚注参考,[^1] 和另一个。[^longnote]

    [^1]:这是脚注。

    [^longnote]:这是一个有多个块的。

    Subsequent paragraphs are indented to show that they
    

    属于上一个脚注。

        { some.code }
    
    The whole paragraph can be indented, or just the first
    line.  In this way, multi-paragraph footnotes work like
    multi-paragraph list items.
    

    这一段不会成为笔记的一部分,因为它 没有缩进。


    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-15
      • 1970-01-01
      • 1970-01-01
      • 2022-11-07
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      相关资源
      最近更新 更多