Hugo-Academic theme not rendering Rmd (YiHui's Rmd example)

Hi,

I've tried making my first blogdown post with Rmarkdown "Hello Blogdown" using Addins -> NewPost, giving a title "Hello Blogdown" and selecting '.Rmd' and leaving all else default.

I then copy in Yihui's example script for Rmarkdown:

(ignore the forward slashes)

\```{r cool-plot, fig.width='80%', fig.cap='A cool plot.'}
plot(cars, pch = 20)  # not really cool
\```

I then use add-ins serve site.
This resulted in following error message in the Rstudio console:

Rendering content/post/2018-05-11-hello-blogdown.Rmd
Quitting from lines 16-17 (2018-05-11-hello-blogdown.Rmd) 
Error in options[[sprintf("fig.%s", i)]] * options$dpi : 
  non-numeric argument to binary operator
Calls: local ... process_group.block -> call_block -> fix_options -> %n%
Execution halted
<simpleError in render_page(f): Failed to render 'content/post/2018-05-11-hello-blogdown.Rmd'>

When I remove the code it serves fine with an appropriately titled post.

Any advice warmly welcomed :slight_smile:

Michael

1 Like

Okay so I found the 'problem'. In the r chunk options, if I remove:

 fig.width='80%'   

We're all good again.

Perhaps academic-theme doesn't 'get' some r chunk figure value options.

Cheers
Michael

I don't think this has to do with Hugo (or the Academic theme). It's knitr that requires fig.width and fig.height to be numeric, and expressed in inches. The more flexible chunk options are out.width/out.height, which can take several different kinds of values as strings. See the documentation here:

It was an unfortunate typo. I meant out.width instead of fig.width. I just updated it in the book per your suggestion at https://github.com/rstudio/blogdown/issues/295. Thanks!

2 Likes