Skip to content

fig.cap= preventing compiling of r markdown document to docx #483

@Hantabaru

Description

@Hantabaru

Have suddenly had problems compiling r markdown to docx with bookdown.

The problem is linked to the fig.cap= option and the label for the code chunk

I asked the question on StackOverflow but have not found a solution.

Stackoverflow question

I have reproduced the problem with an MWE:

---
title: "MWE"
author: "JEB"
date: "13th November 2017"
output:
    bookdown::word_document2:
      fig_caption: true
---

## Including Plots

You can also embed plots, for example \@ref(fig:pressure)

```{r pressure, echo=FALSE, fig.cap="Test"}
plot(pressure)
```

If I include fig.cap="Test caption" I get the following error:

Error in parse_fig_labels(x, global) : 
There are multiple labels on one line: (#fig:pressure), (#fig:pressure) 
Calls: ... -> process_markdown -> parse_fig_labels
Execution halted

If I remove the fig.cap="Test caption", I get the following:

Output created: test.docx
Warning message:
The label(s) fig:pressure not found

And if I do fig_caption= false in the yaml then it compiles no problem

I tried the latest development build of bookdown (0.5.8) with no effect.

Is this a bug?

My sessioninfo, etc are below.

> devtools::session_info('bookdown')
Session info ---------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.383)           
 language (EN)                        
 collate  en_GB.UTF-8                 
 tz       Europe/Oslo                 
 date     2017-11-13                  

Packages -------------------------------------------------------------------------------------------------
 package   * version date       source                           
 backports   1.1.1   2017-09-25 CRAN (R 3.4.1)                   
 base64enc   0.1-3   2015-07-28 CRAN (R 3.4.0)                   
 bitops      1.0-6   2013-08-17 CRAN (R 3.4.0)                   
 bookdown    0.5.8   2017-11-13 Github (rstudio/bookdown@e6b4caa)
 caTools     1.17.1  2014-09-10 CRAN (R 3.4.0)                   
 digest      0.6.12  2017-01-27 CRAN (R 3.4.0)                   
 evaluate    0.10.1  2017-06-24 CRAN (R 3.4.1)                   
 graphics  * 3.4.2   2017-09-28 local                            
 grDevices * 3.4.2   2017-09-28 local                            
 highr       0.6     2016-05-09 CRAN (R 3.4.0)                   
 htmltools   0.3.6   2017-04-28 CRAN (R 3.4.0)                   
 jsonlite    1.5     2017-06-01 CRAN (R 3.4.0)                   
 knitr       1.17    2017-08-10 CRAN (R 3.4.2)                   
 magrittr    1.5     2014-11-22 CRAN (R 3.4.0)                   
 markdown    0.8     2017-04-20 CRAN (R 3.4.0)                   
 methods   * 3.4.2   2017-09-28 local                            
 mime        0.5     2016-07-07 CRAN (R 3.4.0)                   
 Rcpp        0.12.13 2017-09-28 CRAN (R 3.4.2)                   
 rmarkdown   1.7     2017-11-10 CRAN (R 3.4.2)                   
 rprojroot   1.2     2017-01-16 CRAN (R 3.4.0)                   
 stats     * 3.4.2   2017-09-28 local                            
 stringi     1.1.5   2017-04-07 CRAN (R 3.4.0)                   
 stringr     1.2.0   2017-02-18 CRAN (R 3.4.0)                   
 tools       3.4.2   2017-09-28 local                            
 utils     * 3.4.2   2017-09-28 local                            
 yaml        2.1.14  2016-11-12 CRAN (R 3.4.0)                   
> rmarkdown::pandoc_version()
[1] ‘2.0.1.1’
> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Arch Linux)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.61.0
> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions