Code chunk highlighting when chunk has a pagebreak in pdf (knitr)
Asked Answered
Z

0

7

Here is an .Rnw file containing a random code chunk that is, when knitted to pdf, printed on two pages. I noticed that code chunk highlighting stops after a pagebreak.

  1. Why is that?
  2. How do I fix it?

The .Rnw file

\documentclass{article}

%%% Knitr setup
<<include=FALSE, cache=FALSE>>=
library(knitr)
@

\begin{document}
$\;$
\vspace{15cm}
<<eval = FALSE>>=
model <- "
# Measurement models
PR =~ PR1 + PR2 + PR3
IM =~ IM1 + IM2 + IM3
DI =~ DI1 + DI2 + DI3
AD =~ AD1 + AD2 + AD3
DL =~ DL1 + DL2 + DL3
AA =~ AA1 + AA2 + AA3 + AA4 + AA5 + AA6
LO =~ LO1 + LO3
QL =~ QL1 + QL2 + QL3 + QL4 + QL5 + QL6

# Composite model for second-order construct BR
BR <~ QL + LO + AA

# Structural model
BR ~ PR + IM + DI + AD + DL 
"
@
\end{document}

Screenshot of the pagebreak with missing code highlighting after the break.

enter image description here

Zerla answered 25/4, 2020 at 12:35 Comment(2)
I think the first chunk should be after \begin{document}, or?Ordinate
No it can be in the preamble.Zerla

© 2022 - 2024 — McMap. All rights reserved.