With the YAML option `fig-pos: 'h'`, the following chunk

```
::: {#fig-somefigure}

![](figures/somefile)

A caption

:::
```
leads to the following invalid LaTeX code which fails to compile due to the nested figure environments.

```
\begin{figure}

{\centering 

\begin{figure}[ht!]

{\centering \includegraphics{./figures/somefile.png}

}

\end{figure}

}

\caption{\label{fig-somefigure}A caption}

\end{figure}

```

This behaviour is inconsistent: I have blocks of code that are exactly the same format and compile just fine. Instances with `knitr::include_graphics()` also work or systematically fail.

Removing `fig-pos` from the YAML file fixes the problem, which suggests it's the likely culprit...
2022-05-06T22:26:49Z
lbelzile
closed
Quarto not rendering proper LaTeX code when specifying option `fig-pos` [PDF]
https://github.com/quarto-dev/quarto-cli/issues/821