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

prevent-figures-from-floating error #364

Open
MichaelFolkes opened this issue Jan 26, 2022 · 3 comments
Open

prevent-figures-from-floating error #364

MichaelFolkes opened this issue Jan 26, 2022 · 3 comments

Comments

@MichaelFolkes
Copy link

The example
https://bookdown.org/yihui/rmarkdown-cookbook/figure-placement.html#prevent-figures-from-floating
failed for me with an error: unknown float option 'H' (writing that from memory so wording might be incorrect).
However removing the "!" from fig.pos = !H allowed the .rmd to compile

@cderv
Copy link
Collaborator

cderv commented Jan 27, 2022

unknown float option 'H'

Did you correctly load the float package as in the example ?

output: 
  pdf_document:
    extra_dependencies: ["float"]

It is common error message (https://fr.overleaf.com/learn/latex/Errors/LaTeX_Error%3A_Unknown_float_option_%60H%27)

@jmarshallnz
Copy link

jmarshallnz commented May 23, 2022

Just confirming that this issue exists, but only when fig.cap is set on a figure.

With fig.pos = "!H" you get the classic "unknown float option 'H'" error. Even with extra_dependices: ["float"] as required.

Changing it to fig.pos="H" results in a clean knit.

This can be reproduced easily with the default .Rmd generated from "New R Markdown" by specifying:

output:
  pdf_document:
    extra_dependencies: ["float"]

and altering the first chunk to be:

knitr::opts_chunk$set(echo = TRUE, fig.cap='foo', fig.pos = "!H", out.extra = "")

Knitting will then produce this error. As @MichaelFolkes suggests, dropping down to fig.pos="H" works.

Presumably it's due to an additional package loaded when figure captions are given which conflicts with the float package.

@cderv
Copy link
Collaborator

cderv commented May 23, 2022

Thanks for the additional information @jmarshallnz.

I tried to remove some of the packages to find a possible conflict, but without success.
Do we have a working example in LaTeX using \begin{figure}[!H] ? I can't seem to make one working with a simple document .tex to compile to .pdf.

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

3 participants