0

I have a LaTeX section that I put at the top of my knitr generated PDF document. I achieved this by using the YAML options

output:
    pdf_document: 
        includes: 
            before_body: file.tex

file.tex contains code like this

\textsf{Reporting: `r 2+2`}

but this doesn't work. Is there another way that I can get this value? Passing in a parameter is fine if that's possible.

Thanks!

Unrelated: I could not use the tag 'YAML'.

  • I do not know knitr (just the concept). I would assume that your example puts document code before the document (= preamble) which is not allowed. – Dr. Manuel Kuehner Apr 17 '18 at 15:52
  • The code snippet is YAML. the before_body: tag places code just below the /begin{document} so it is the first to appear. All code works except the R. – DonkeyKong Apr 17 '18 at 15:56
  • So in \textsf{Reporting: 'r 2+2'} the 'r 2+2' part should be replaced by a plain 4? ( I use ' because `does not work here). – Dr. Manuel Kuehner Apr 17 '18 at 15:59
  • That's the desired result. I am pretty sure that the way I have it coded will never work since the file is external and is included as a .tex file. – DonkeyKong Apr 17 '18 at 16:01
  • 1
    Please refrain from cross-posting: stackoverflow.com/q/49881851/559676 – Yihui Xie Apr 17 '18 at 18:48

Your Answer

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

Browse other questions tagged or ask your own question.