Как сгенерировать список таблиц и рисунков приложения в начале приложения в Rmarkdown pdf_document - PullRequest
0 голосов
/ 23 мая 2019

Я пишу статью в Rmarkdown, и мне нужно создать список таблиц и рисунков в начале приложения.Я вручную ввел такой список в следующем примере кода.Как я могу получить этот список для автоматического создания?Также как я могу гарантировать, что только часть рисунка и подписи к таблицам будут использоваться в качестве заголовков в списке таблиц и рисунков?Я предполагаю, что есть некоторые заголовки LaTeX, которые нужно добавить, но я не могу найти правильный пакет.

---
title: "Nice title"
author: ""
output:
  pdf_document: 
    number_sections: false
    fig_crop: true
    toc: false
    keep_tex: false
header-includes:
   - \usepackage{caption,booktabs,longtable,pdfpages,rotating,graphicx,footmisc,float}
   - \captionsetup{width=5in}
   - \setlength\parindent{24pt}  
   - \bibliographystyle{apsr}
fontsize: 11pt
references:
- id: fenner2012a
  title: One-click science marketing
  author:
  - family: Fenner
    given: Martin
  container-title: Nature Materials
  volume: 11
  URL: 'http://dx.doi.org/10.1038/nmat3283'
  DOI: 10.1038/nmat3283
  issue: 4
  publisher: Nature Publishing Group
  page: 261-263
  type: article-journal
  issued:
    year: 2012
    month: 3  
---

```{r echo=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```


Main text here [@fenner2012a].

\newpage

# References {-}

<div id="refs"></div>

\newpage 

# Appendix {-}

[THIS IS WHERE I WANT TO HAVE A LIST OF APPENDIX TABLES AND FIGURES. IT WOULD LOOK SOMETHING LIKE:]

Figures:

Figure A1: I would like this sentence only to appear in the list of figures. .... 1

Tables:

Table A1: I would like this sentence only to appear in the list of tables. .... 1


\setcounter{page}{0}
\pagenumbering{arabic}
\setcounter{page}{1}


\setcounter{figure}{0}
\setcounter{table}{0}
\renewcommand{\thefigure}{A\arabic{figure}}
\renewcommand{\thetable}{A\arabic{table}}


\newpage 


```{r results='asis', fig.cap="I would like this sentence only to appear in the list of figures. Here is some other text to describe the figure that should not appear in the text giving the list of figures."}
p <- rnorm(100)
plot(p)
```


```{r results='asis'}
library(kableExtra)
q <- rnorm(5)
kable(q, caption = "I would like this sentence only to appear in the list of tables. Here is some other text to describe the figure that should not appear in the text giving the list of tables.")
```
...