knitr::opts_chunk$set(echo = TRUE)
library(matlib)

HTML documents use a different notation for labels and equation references. This is the cannonical way.

\begin{equation} 
(\#eq:binom)
  f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
\end{equation} 

The equation \@ref(eq:binom) ...

which gives

\begin{equation} (#eq:binom) f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} \end{equation}

The equation \@ref(eq:binom) ...

Eqn() now detects that an HTML document is being compiled and changes the labels to match. This means that \@ref(eq:binom) should be used instead of the LaTeX \ref{eq:binom} way.

Eqn("\\mathbf{X} = ",  latexMatrix())

Can I reference this as: See \@ref(eq:X)

Inline reference via R ref()

Much like using \label{eqn:lab} for \LaTeX\ and \(#eq:lab) for HTML, switching between \ref{.} and \@ref(.) is a little annoying. Instead, you can use ref('eq:label') to create the correct reference form regardless of the output type.

For example, reference the previous equation "eq:X" via the r inline mode with ref("eq:X") gives r ref("eq:X").



friendly/matlib documentation built on Dec. 6, 2024, 9:25 a.m.