2

I am using knitr and want to insert a line break in my fig.cap chunk option. Is this possible? The following is all I can think of but it doesn't work. I expect there's some evaluation option but I struggle to understand how evaluation works...

\documentclass{article}

\begin{document}

<<chunk1, fig.cap = "This figure is great! Do you \n agree?">>=
plot(1:10)
@


\end{document}

1 Answer 1

4

Use a LaTeX linebreak instead of an R linebreak and use the caption package. The following works for me:

\documentclass{article}

\usepackage[format=plain, justification=raggedright,singlelinecheck=true]{caption}

\begin{document}

<<chunk1, fig.cap = "This figure is great! Do you \\\\ agree?">>=
plot(1:10)
@

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .