Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fig.ncol not working with Latex #2336

Open
3 tasks done
nassuphis opened this issue Apr 14, 2024 · 2 comments
Open
3 tasks done

fig.ncol not working with Latex #2336

nassuphis opened this issue Apr 14, 2024 · 2 comments

Comments

@nassuphis
Copy link

this should produce 2 figures per column:

\documentclass{article}
\begin{document}
<<,fig.show = "hold",out.width = "2cm",fig.ncol=2>>=
plot(1:100); plot(100:1); plot(1:100); plot(100:1); plot(1:100) 
@
\end{document}

it used to work.

now it produces this:

image

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@nassuphis
Copy link
Author

> xfun::session_info()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1, RStudio 2023.12.1.402

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  callr_3.7.6       cli_3.6.2         compiler_4.3.3    curl_5.2.1        desc_1.4.3        evaluate_0.23     graphics_4.3.3   
  grDevices_4.3.3   highr_0.10        knitr_1.46.3      methods_4.3.3     pkgbuild_1.4.4    processx_3.8.4    ps_1.7.6         
  R6_2.5.1          remotes_2.5.0     rstudioapi_0.16.0 stats_4.3.3       tools_4.3.3       utils_4.3.3       xfun_0.43        
  yaml_2.3.8       
> 

@cderv
Copy link
Collaborator

cderv commented Apr 23, 2024

fig.ncol is used for sufigure and so you need to use fig.cap and fig.subcap for it to be used, also adding usage for the subfig package.

We document this in https://bookdown.org/yihui/rmarkdown-cookbook/latex-subfigure.html

fig.ncol is not used otherwise.

Example:

\documentclass{article}
\usepackage{subfig}
\begin{document}
<<out.width = "50%",fig.ncol=2, fig.subcap=letters[1:5], fig.cap="test">>=
plot(1:100); plot(100:1); plot(1:100); plot(100:1); plot(1:100)
@
\end{document}

Codebase for this in https://github.com/yihui/knitr/blob/44a7bee566afff3eb4c8b13fd6fa64487e12981f/R/hooks-latex.R

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants