What is the right way to get knitr to do cross-references? The recommended approach in the documentation (see below) doesn't work for me. I am writing a book with knitr and the tufte_book template. I can't seem to get the cross references to figures (or tables) to work correctly. I've enclosed a small clip that consistently fails to get the cross refs updated in the document. Im running R 3.2.3 on x86_64-apple-darwin13.4.0. I know this question has been answered before, but all the answers fail in the same way. No, I don't want to use bookdown.
---
title: "Cross-references SNAFU"
output:
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
---
```{r ch3-inits, include=FALSE}
library(tufte)
library(knitr)
knitr::opts_chunk$set(eval.after = 'fig.cap')
```
\chapter{Not Working Cross References, the beginning \label{chap:alpha} }
```{r t-test, fig.cap=paste('$2 \\times 2$ is', 2*2), fig.height=2.5}
x = rnorm(30)
par(mar=c(4, 4, .1, .1))
hist(x, main='')
```
Here is the reference to that Figure \ref{fig:t-test}. NOT.
Here is a clip of the output: resultant pdf output