eddelbuettel / pinp

Pinp Is Not PNAS -- Two-Column PDF Template
147 stars 25 forks source link

figure size #72

Closed Courvoisier13 closed 5 years ago

Courvoisier13 commented 5 years ago

When I do a figure using a

> ```{r, fig.pos='H', fig.cap="Text"}
> some ggplot image
> ```

the figure text font is too large when compared to the regular text (fontsize 9). In regular markdown, I can control that in the yaml header, ex:

output: 
  pdf_document:
    fig_height: 5
    fig_width: 6

But pinp does not offer that option. When I set the options:

knitr::opts_chunk$set(fig.width = 6, fig.height = 5)

it just increases the size of the figure and goes out of the column.

Is there a way to set fig_height and fig_width of the document?

thanks

eddelbuettel commented 5 years ago

Please see the included demos, and public use cases as eg the Rcpp Intro vignette and please try to not open a new issue every few minutes.

eddelbuettel commented 5 years ago

See this pdf as one example for explicitly sized graphs / two-column graphs. The source is here -- we are also plain latex tricks. The file is also a demo of using the bibliographic.

pinp may not be the most beginner-friendly Rmarkdown option as it is somewhat specialised in its focussed look and feel. I hope you find it useful and encourage you to explore -- but keep in mind that not all Rmarkdown tutorials and cheatsheets will apply.

Sorry for the delay but I am out at conference.

Courvoisier13 commented 5 years ago

ah I see, you create the pdf first then insert it. Ok, thanks.

eddelbuettel commented 5 years ago

One of many ways. You can also do the knitr on demand way but check what the code does. This is by design a highly specialised package for (R)Markdown to not every generic howto on rmarkdown or knitr you read may apply here. Eg the defaults are set here

https://github.com/eddelbuettel/pinp/blob/01a98d33c427c1dac1f7cb7487b4b8a00bd1fe16/R/pinp.R#L116-L118

and those are fixed. But knitr lets you set global overrides the usual way. And no, these values are not set-able in the YAML header.

Courvoisier13 commented 5 years ago

Yes, I ended up doing that. So the way I used to do, is have 2 controls. 1- the size of the pdf (ps) figure produced by say ggplot and 2- the size of the output forced produced by Rmarkdown. If I made the size of 1 large and 2 small, the fonts became smaller automatically, allowing me a lazy way of controlling sizes and fonts in one go. However, by explicitly controlling font sizes in the ggplot theme, and then using opts_chunk$fig.width as you pointed out I get the right results as well.