12

I often have questions about using LaTeX in Rmarkdown, specifically about changing the header of the TeX file from within Rmarkdown, using header-includes and suppressing some of the default functions.

For example, this solution works in a TeX file, but does not work in header-includes, because of spaces, enters, or entire commands that cannot be entered there.* Removing spaces and commands until it does work is often the only solution. As far as I'm concerned, header-includes sends arguments followed by a dash - to a new rule in the header, so I'd like to understand why certain commands don't work.

When Googling these problems, there is often limited information concerning Rmarkdown specifically so I would like to know if there is a better place for these questions or whether they are appropriate for tex.stackexchange.com.

I am asking because of this question that I have been meaning to ask, but wasn't sure whether I could ask here.

* Removing all comments, {}[] after each new command and removing all enters and spaces works in Rmarkdown, but I do not understand the reason for it.

Edit
To clarify, I am referring to using LaTeX in an Rmarkdown file, not using Rmarkdown's own syntax.

5
  • 2
    Rmarkdown as far as I know, mimics TeX commands in the parser but itself does not use TeX. So if that's the case then they are off-topic
    – percusse
    Commented Oct 5, 2017 at 15:44
  • Thank you for your reply, what do you mean by mimics TeX commands in the parser? If I understand correctly, Rmarkdown uses pandoc to compile a combination of Rmarkdown and LaTeX to a .tex file. Commented Oct 6, 2017 at 2:25
  • 1
    @percusse I don't think that quite true. pandoc does the conversion and you can put raw latex into your document I think. So I think that the questions are in principle on topic. That being said, I think you may well get some pushback in comments from people who will think it is off topic.
    – Alan Munn
    Commented Oct 7, 2017 at 22:48
  • @AlanMunn From that we can conclude that I don't know anything about RMarkdown apparently
    – percusse
    Commented Oct 7, 2017 at 23:06
  • 2
    as Alan says in his answer the questions are mostly on topic if they can be phrased about tex rather than the surrounding R syntax. It helps if you can post the generated tex file so it can be answered as a straight tex question by someone without R, if you are getting R errors and not generating a tex file, it's an indication that it may be off topic here Commented Oct 7, 2017 at 23:55

1 Answer 1

17

I think that such questions are on-topic, although if you just post the RMarkdown code itself you probably limit the number of site users who will be able to answer the question, and you may get push back in comments about the question being off topic.

If you do get comments about closing, and my answer here gets upvoted with no opposing answers, then I would keep this link handy; sometimes close voters get trigger happy.

The question as you've posed it seems fine to me, since you've added the generated LaTeX file as well as the RMarkdown source. I think that's a good strategy for any further questions you might have.

You must log in to answer this question.

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