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

LaTeX to HTML conversion: \label and \ref work for figures but not equations #10176

Open
lnelson2382 opened this issue Sep 12, 2024 · 4 comments
Labels

Comments

@lnelson2382
Copy link

Explain the problem.
When converting LaTeX input to HTML output with mathML, \ref{label} commands within the text get converted to in-page hyperlinks. These hyperlinks work correctly for sections and figures, as the corresponding HTML objects are given the marker id="label", but not for equations, which just end up with dead hyperlinks.

Sample input file "label.tex":

\documentclass{article}
\begin{document}
\section{Section} \label{section}
\begin{equation}
\label{eq:sample}
y^2 = a x^3 + bx + c
\end{equation}
This is Equation~\ref{eq:sample}, in Section~\ref{section}, with Figure~\ref{fig:sample}
\begin{figure}
\centering
\begin{tabular}{c|c}
1 & 0 \
0 & 1
\end{tabular}
\label{fig:sample}
\caption{A figure}
\end{figure}
\end{document}

Pandoc Command
pandoc -f latex -t -html --mathml label.tex -o label.html

Expected vs Actual Result
The html file which is produced contains three internal hyperlinks; the links to the section and the figure work correctly, but the link to the figure leads to a nonexistent location in the page.

Pandoc version?
Pandoc 3.4 (Windows x86_64)
Pandoc 2.5 (Ubuntu on WSL)

@lnelson2382
Copy link
Author

(I should specify - the Windows version is Windows 10)

@tarleb
Copy link
Collaborator

tarleb commented Sep 12, 2024

I've written a Lua filter for this, querverweis. It is work in progress, but I'd be happy to try and make it work for your usecase.

@lnelson2382
Copy link
Author

Thanks for the suggestion! I downloaded the filter, and it seems to make the equation linking work, but it also strips out semantically important spaces, such as turning the valid LaTeX $\omega t$ into the nonsensical $\omegat$. I can look for a minimal example and submit a bug report to your repository if that will be helpful.

@tarleb
Copy link
Collaborator

tarleb commented Sep 15, 2024

That's weird. Please open a bug report there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants