quarto-dev / quarto-dev/quarto-cli

Passing LaTeX argument argument to `\includegraphics{}` (e.g `draft`)

Open
#6,239 1 comment 0 reactions 1 assignee View on GitHub

@cscheid is already working on this.

Since Jul 18, 2023.

crossref enhancement latex
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/6234

Originally posted by ramiromagno July 17, 2023

Description

Is there a simple way of adding the draft option to:

https://github.com/ramiromagno/wiley-njd/blob/885a1827617952d3d01156ab68e6af8c8e118337/template.qmd#L131

such that instead of getting:

\begin{figure}[t]
{\centering \includegraphics[width=\textwidth,height=1.5in]{empty.pdf}}
\caption{\label{fig-fig1}This is the sample figure caption.}
\end{figure}

I would get the argument draft passed on to \includegraphics{}:

\begin{figure}[t]
{\centering \includegraphics[width=\textwidth,height=1.5in, draft]{empty.pdf}}
\caption{\label{fig-fig1}This is the sample figure caption.}
\end{figure}

Details

We could expect to do it like

![This is the sample figure caption.](empty){#fig-fig2 draft=true}

However this does not work. Currently I don't think Pandoc supports passing any attributes to LaTeX. They are ignored.

knitr does have a out.extra chunk option that allows that;

```{r}
#| fig.cap: This is the sample figure caption.
#| out.extra: draft
knitr::include_graphics("empty", error = FALSE)
```

but knitr does write the LaTeX markup directly in that case, and does not rely on Pandoc.
Note: This does not work in Quarto because quarto will always enforce Markdown syntax for image for all knitr output.

Not sure we can improve the feature without Pandoc support... 🤔 But still opening the issue to track the idea.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.