quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.93k stars 324 forks source link

cross-reference labels from raw latex #1199

Open amichuda opened 2 years ago

amichuda commented 2 years ago

If I create a figure or table in raw latex:

\begin{figure}[h!]
\begin{center}
\includegraphics[width=\textwidth]{figure/path}
\end{center}
\caption{My caption}
\label{fig-label}
\caption*{\footnotesize Note: A note}
\end{figure}

I can't cross-reference @fig-label. Is that by design? Is there some way to have them be cross-references as a workaround?

The reason I need to use raw latex instead of using markdown, is that I need a note underneath the figure. If there's some way to do that with using markdown, that would be even better!

jjallaire commented 2 years ago

The issue is that because you've manually inserted the label the Quarto crossref system doesn't know about it.

We have another feature request for multi-line captions (https://github.com/quarto-dev/quarto-cli/issues/645) which once implemented should be a way to address this problem.

amichuda commented 2 years ago

Thank you! Do you have a sense of how big a priority that is for the project right now?

EDIT: And if it's not, do you have any ideas on a workaround for now?

jjallaire commented 2 years ago

It seems like something that many users clearly need, so we'll likely do it for our v1.1 release (early fall).

juliantao commented 2 years ago

I had the same problem before and a workaround is that you can use the raw LaTex cross-reference syntax, e.g., \ref{fig-label}. But this will only give you the figure number, you may need to manually add the prefix such as Figure \ref{fig-label}

amichuda commented 2 years ago

I had the same problem before and a workaround is that you can use the raw LaTex cross-reference syntax, e.g., \ref{fig-label}. But this will only give you the figure number, you may need to manually add the prefix such as Figure \ref{fig-label}

Thank you so much! I think that will suffice while I wait for the update. But also, man, Quarto is so good, I love this thing!

phongphuhanam commented 1 year ago

I had the same problem and I changed param("crossref-resolve-refs", true) to param("crossref-resolve-refs", false) in this file ref.lua. This way I can use the same Quarto cross-reference syntax for table without changing it to Latex \ref keyword like @juliantao method. Hope this help.