Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

caption numbering not in sequential order when citing the captions #36

Open
raiphilibert opened this issue Aug 29, 2018 · 1 comment
Open

Comments

@raiphilibert
Copy link

The caption number is not in sequential order when citing the captions but only if the table_nums(..., display="cite") is before the tables. I was trying to give the range of table numbers and it changed the number of the last table. Is there a way to make sure that table numbers remain in sequential order? The number isn't changed if the r table_nums('third_cars_table',display = "cite") is put after the captions.

Reproducible example:

---
title: "Untitled"
output: bookdown::word_document2
---

```{r setup, include=FALSE}
library(captioner)
library(huxtable)
library(knitr)
library(pander)
table_nums <- captioner(prefix = "Table")
fig_nums <- captioner(prefix = "Figure")
knitr::opts_chunk$set(echo = TRUE)
`` `


## Description of tables
I am trying to put a description of tables 
and say that these results are shown table numbers ranging 
from the first table (`r table_nums('first_cars_table',display = "cite")`)
 to the last table (`r table_nums('third_cars_table',display = "cite")`)

```{r, results='asis',echo=FALSE,eval.after=TRUE}
tablecap1=cat(table_nums(name="first_cars_table",caption='First car table'))
kable((cars[1:5,]))

tablecap2=cat(table_nums(name="second_cars_table",caption='second car table'))
kable(cars[6:10,])

tablecap3=cat(table_nums(name="third_cars_table",caption='third car table'))
kable(cars[10:15,])
`` `

The results:
captioner_issue

@dr-harper
Copy link

dr-harper commented Oct 14, 2018

I can't help with the issue directly within captioner, but I can offer you an easier workaround to the problem.

It is my understanding that most of the functionality of this package has been directly included within bookdown package, removing a lot of the additional code required: #29

You may wish to read about this more here. As an example of your probem:

---
title: "Untitled"
output: bookdown::word_document2
---

```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = FALSE)
```

## Description of tables

I am trying to put a description of tables and say that these results are shown table numbers ranging from the first table (Table \@ref(tab:cars1)) to the last table \@ref(tab:cars3))


```{r cars1}
kable(cars[1:5,], caption = "First car table")
```

```{r cars2}
kable(cars[6:10,], caption = "Second car table")
```

```{r cars3}
kable(cars[10:15,], caption = "Third car table")
```

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants