2
votes

I have small bookdown 'book' that includes the following code:

A concept map is a diagram that shows 'ideas' and the relationship between those ideas. An example of a concept map is shown in Figure \@ref(fig:exampleCM).


```{r exampleCM, fig.show='hold', fig.cap='An example concept map --- Source: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/d/df/Conceptmap.png "Concept Map from Wikipedia")', echo=FALSE}                                  

knitr::include_graphics('images/ConceptMap.png')                                                                                                            
```                                                                                                                                                         

If I render the book as HTML everything works as expected. The caption includes a hyperlink to wikimedia/wikipedia. I.e., the caption looks like this:

Figure E.1: An example concept map — Source: Wikipedia

If I render the book as PDF, the caption in the PDF looks like this:

Figure E.1: An example concept map -- Source: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/d/df/Concep "Concept Map from Wikipedia")

It seems that the rmarkdown doesn't get rendered for some reason. The LaTeX file that is produced is like this:

A concept map is a diagram that shows `ideas' and the relationship between those ideas. An example of a concept map is shown in Figure \ref{fig:exampleCM}.

\begin{figure}
\includegraphics[width=12.33in]{images/ConceptMap} \caption{An example concept map --- Source: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/d/df/Conceptmap.png "Concept Map from Wikipedia")}\label{fig:exampleCM}
\end{figure}

I wonder how I might fix this.

1
This feels a bit like this other problem I reported with captions. - Peter Smith
You have to use text references in this case: bookdown.org/yihui/bookdown/… - Yihui Xie

1 Answers

0
votes

The comment above by Yihui Xie did the trick.

Thanks for reminding me about text references.