arcaldwell49 / cik-quarto

Communications in Kinesiology Quarto templates for typesetting
MIT License
0 stars 0 forks source link

PDF figures do not resize in PDF output #6

Open smnnlt opened 7 months ago

smnnlt commented 7 months ago

The PDF output of the template does not resize PDF figures to the page size, even when including the {out-width="100%"} option. Large PDF figures will overflow the page. This seems to be related to the template as there is no problem in normal Quarto PDF output. Whether the figure is a stand-alone figure, in a div, or a subfigure, seems to have no effect.

I could only test the figure resizing for Quarto version 1.3.450, because of https://github.com/arcaldwell49/cik-quarto/issues/5.

arcaldwell49 commented 7 months ago

Very weird, quarto team really messed something up in an update somewhere.

Add this to the partial file titled "before-body.tex" after the \maketitle and \newpage commands

$if(graphics)$
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
$endif$
arcaldwell49 commented 7 months ago

Note: I will add this to the template. Just add that to the partials for the current manuscript you're working on.

arcaldwell49 commented 7 months ago

Also, for figure 2, please use the following code chunk

::: {#fig-2,layout-ncol="1"}
![](fig2a.png)

![](fig2b.png)

![](fig2c.png)
**Figure 2:** Time-on-target durations for all experimental groups in the easy task (a), the moderate difficulty task (b), and the hard task (c). Error bars represent 95% confidence intervals.
:::
smnnlt commented 7 months ago

Thanks, the partial file code worked for me, although I had to put \usepackage{graphicx} in _preamble.txt

smnnlt commented 7 months ago

Also, for figure 2, please use the following code chunk

::: {#fig-2,layout-ncol="1"}
![](fig2a.png)

![](fig2b.png)

![](fig2c.png)
**Figure 2:** Time-on-target durations for all experimental groups in the easy task (a), the moderate difficulty task (b), and the hard task (c). Error bars represent 95% confidence intervals.
:::

You're right, the {out-width="20%"} were products of my earlier experiments that I missed to delete. I deliberately did not write the caption as a main caption but as the caption of the last subfigure, otherwise I got problems in the html formatting. I'll open a new issue for this.

arcaldwell49 commented 7 months ago

Yeah, we really shouldn't have separate files for one figure. I've emailed the authors to avoid this issue.