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

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

Open
cderv opened this issue Jul 17, 2023 Discussed in #6234 · 1 comment
Open

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

cderv opened this issue Jul 17, 2023 Discussed in #6234 · 1 comment
Assignees
Labels
crossref enhancement New feature or request latex LaTeX engines related libraries and technologies
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Jul 17, 2023

Discussed in #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.

@cderv cderv added this to the Future milestone Jul 17, 2023
@cderv cderv added latex LaTeX engines related libraries and technologies enhancement New feature or request labels Jul 17, 2023
@cscheid cscheid self-assigned this Jul 18, 2023
@cscheid
Copy link
Collaborator

cscheid commented Jul 18, 2023

If it's a crossreferenceable image, we have stronger control over the LaTeX we emit. It might be possible to do it in #4944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crossref enhancement New feature or request latex LaTeX engines related libraries and technologies
Projects
None yet
Development

No branches or pull requests

2 participants