簡體   English   中英

在 rmarkdown 標題中添加腳注

[英]Adding a footnote in rmarkdown header

我在 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}}

會話信息()

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

你可以這樣做:

---
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.

這一段不會成為注釋的一部分,因為它沒有縮進。


如果您嘗試rmarkdown::render('~/test_.rmd', encoding = 'UTF-8')會發生這種情況嗎? sessionInfo()結果是什么?

你可以這樣做

---
title: "Untitled"
author: |
  "anonymous\footnote{"no one knows me"}
output: pdf_document
---

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM