英文:
Spacing for multiple footnotes on one paragraph in r markdown
问题
这是一个相当简单的问题,应该有一个简单的解决方案,对吧?我一直在尝试删除脚注编号与文本之间的空格,我可能需要一些帮助。
这是一些示例代码:
dat$place <- c("South Atlantic", "Gulf of Mexico", "Pacific")
Footnotes.list$ft_IOModel <- "Footnote_1"
Footnotes.list$ft_EFL <- "Footnote_2"
Footnotes.list$ft_WFL <- "Footnote_3"
for (i in 1:length(dat$place)) {
rmarkdown::render(Comm_Region.Rmd,
output_dir = output,
output_file = paste0(filename,".docx"))
}
这是 Comm_Region.Rmd
的 markdown 代码(关注 "South Atlantic" 和 "Gulf of Mexico" 的部分):
retailers.`r if(place == "South Atlantic") {
paste0("^[",Footnotes.list$ft_IOModel,"] ^,^ ^[", Footnotes.list$ft_EFL,"]")}
else if (place == "Gulf of Mexico") {
paste0("^[",Footnotes.list$ft_IOModel,"] ^,^ ^[", Footnotes.list$ft_WFL,"]")}
else {
paste0("^[",Footnotes.list$ft_IOModel,"]")}`
我明白我需要删除逗号之前和之后的空格 ( ^,^ ^
) 以获得所需的输出;然而,当我这样做时,整个代码会崩溃,脚注不再出现在页面底部。我也尝试过使用LaTex,但无济于事。肯定有更好的方法来编写这段代码。有任何建议吗?
英文:
This is a rather simple problem that should have a simple solution, right? I have been trying to remove the space between footnote numbers and I could use some help.
Here is some sample code:
dat$place <- c("South Atlantic", "Gulf of Mexico", "Pacific")
Footnotes.list$ft_IOModel <- "Footnote_1"
Footnotes.list$ft_EFL <- "Footnote_2"
Footnotes.list$ft_WFL <- "Footnote_3"
for (i in 1:length(dat$place)) {
rmarkdown::render(Comm_Region.Rmd,
output_dir = output,
output_file = paste0(filename,".docx"))
}
Here is the Comm_Region.Rmd markdown code (focusing on the code for "South Atlantic" and "Gulf of Mexico"):
retailers.`r if(place == "South Atlantic") {
paste0("^[",Footnotes.list$ft_IOModel,"] ^,^ ^[", Footnotes.list$ft_EFL,"]")}
else if (place == "Gulf of Mexico") {
paste0("^[",Footnotes.list$ft_IOModel,"] ^,^ ^[", Footnotes.list$ft_WFL,"]")}
else {
paste0("^[",Footnotes.list$ft_IOModel,"]")}`
I understand that I need to remove the spaces before and after the comma ( ^,^ ^
) to get the desired output; however, when I do that the whole code breaks and the footnotes no longer appear at the bottom of the page. I've also tried LaTex but to no avail. There must be a better way to write this. Any suggestions?
答案1
得分: 1
如果您愿意在LaTeX中工作,可以使用`fnpct`包来帮助。
---
title: "多个脚注"
output: pdf_document
header-includes:
- \usepackage{fnpct}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
place <- "South Atlantic"
Footnotes.list <- list()
Footnotes.list$ft_IOModel <- "脚注 1"
Footnotes.list$ft_EFL <- "脚注 2"
Footnotes.list$ft_WFL <- "脚注 3"
零售商。r if(place == "South Atlantic"){ paste0("\\footnote{", Footnotes.list$ft_IOModel, "}\\footnote{", Footnotes.list$ft_EFL, "}") }else if(place == "Gulf of Mexico"){ paste0("\\footnote{", Footnotes.list$ft_IOModel, "}\\footnote{", Footnotes.list$ft_WFL, "}") }else{ paste0("\\footnote{", Footnotes.list$ft_IOModel, "}") }
[![在此输入图片说明][1]][1]
[1]: https://i.stack.imgur.com/hajE6.png
英文:
If you are happy to work in LaTeX this may help using fnpct
package.
---
title: "Multiple footnotes"
output: pdf_document
header-includes:
- \usepackage{fnpct}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r footnotes, include=FALSE}
place <- "South Atlantic"
Footnotes.list <- list()
Footnotes.list$ft_IOModel <- "Footnote 1"
Footnotes.list$ft_EFL <- "Footnote 2"
Footnotes.list$ft_WFL <- "Footnote 3"
```
Retailers.`r if(place == "South Atlantic"){
paste0("\\footnote{", Footnotes.list$ft_IOModel, "}\\footnote{", Footnotes.list$ft_EFL, "}")
}else if(place == "Gulf of Mexico"){
paste0("\\footnote{", Footnotes.list$ft_IOModel, "}\\footnote{", Footnotes.list$ft_WFL, "}")
}else{
paste0("\\footnote{", Footnotes.list$ft_IOModel, "}")
}`
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论