Note that there are some explanatory texts on larger screens.

plurals
  1. POChunk reference using knitr, r markdown and pandoc (pander)
    text
    copied!<p>I am having trouble trying to reference chunks within a r markdown document which I am trying to convert to .pdf using pandoc.convert. </p> <p>If I include <code>\label{mylabel}</code> within the text - I can reference this by <code>\ref{mylabel}</code>. However, I thought I might be able to refer to a chunk (or table / figure within a chunk) similarly - but am having no luck. </p> <p>For instance, for the chunk:</p> <pre><code>```{r myplot, echo=FALSE, warning=FALSE} plot(cars) ``` </code></pre> <p>I though I might be able to put <code>\ref{myplot}</code> or <code>\ref{fig:myplot}</code> or even an internal markdown reference <code>[car plot](myplot)</code>. The documentation seems to mention that labels are created based on the name of the chunk and these are the formats suggested in relation to similar questions. But none seem to work. </p> <p>Similarly for tables (which I create using pander) - I have chunks like: </p> <pre><code>```{r car_sum} library(pander) car_summary&lt;-summary(cars) pander(car_summary, caption = "This is a summary of cars") ``` </code></pre> <p>When converting to .pdf from the .md file using 'pandoc.convert' the tables are given a nice title 'Table 3 This is a summary of cars' and are numbered but I cannot seem to use the label as a reference <code>\ref{car_sum}</code> and it always shows as '??'. Some forums seem to mention that you have to include 'tab:' or 'fig:' before the label name but this still does not work for me. </p> <p>Can chunk referencing within text be done? If so, what needs to be typed to do this correctly so it works in the final document showing something like 'see Table 2'. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload