Is there a way to force knitr to create tikz code which includes font size information? The output would be something like this:

\begin{tikzpicture}[every node/.style={font=\footnotesize}]

Here is some more background information:

I am currently writing my PhD thesis which is depending on multiple tools (e.g., R, Matlab). In order to document my work as dynamically as possible, I am using knitr for the parts which depend on R. However, I prefer to write most parts of my thesis using TeXstudio. Thus, in order to include the knited R-code in LaTeX I follow this suggestion: I set up a main Rnw-file in which I include child documents. After compiling and kniting the children I put the generated tex-files in the LaTeX files (via input{}).

In principal this approach works fine. However, I can not figure an elegant way of how to set the font size of the nodes and labels to a specific value which is defined through font size modifier-commands.

So far, I fiddled around with the chunk options size and dev.args=list(pointsize=[]). While the first apparently only applies to "real" text and not to text within plots, the second does not set something like font=\footnotesize}. Thus, changes to the pointsize argument do not affect the final appearance of text in figures as the tikz files are eventually compiled with LaTeX (or LuaLaTeX to be precise).

Here is an answer to a similar question which would be neither easily applicable in my case nor did I get it to work for me so far.

One solution I could think of would be to define global tikz styles using \tikzstyle. However, this at least discussed for being bad practice (as described here). Further more, how could I define it for a section in which it would apply also for tex-files that have been included via input{}?

  • This question is a duplicate of the font portion of the first answer in this question. tex.stackexchange.com/questions/169354/… – R. Schumacher Sep 8 '15 at 1:40
  • Well, I know this answer as well. But it does not solve my problem. His suggestion is to work via dev.args=list(pointsize=[]) which does not work in my case. – ToJo Sep 8 '15 at 2:04

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.