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}
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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.