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 figure captions and labels lost as RST output #8930

Closed
peterjc opened this issue Jun 30, 2023 · 2 comments
Closed

LaTeX figure captions and labels lost as RST output #8930

peterjc opened this issue Jun 30, 2023 · 2 comments
Labels

Comments

@peterjc
Copy link

peterjc commented Jun 30, 2023

Explain the problem.

I am converting LaTeX to reStructuredText (RST) using pandoc, but am having trouble with figures (images with captions and usually citable labels).

Sample from larger LaTeX document,

Here are my attempts at UML class diagrams for the \verb|Blast| and \verb|PSIBlast| record classes. If you are good at UML and see mistakes/improvements that can be made, please let me know. The Blast class diagram is shown in Figure~\ref{fig:blastrecord}.


\begin{figure}[htbp]
\includegraphics[width=0.8\textwidth]{images/BlastRecord.png}
\caption{Class diagram for the Blast Record class representing all of the info in a BLAST report}
\label{fig:blastrecord}
\end{figure}

The PSIBlast record object is similar, but has support for the rounds that are used in the iteration steps of PSIBlast. The class diagram for PSIBlast is shown in Figure~\ref{fig:psiblastrecord}.


\begin{figure}[htbp]
\includegraphics[width=0.8\textwidth]{images/PSIBlastRecord.png}
\caption{Class diagram for the PSIBlast Record class.}
\label{fig:psiblastrecord}
\end{figure}

Save this as snippet.tex and then convert to markdown (as an example):

$ pandoc -f latex -t markdown snippet.tex
Here are my attempts at UML class diagrams for the `Blast` and
`PSIBlast` record classes. If you are good at UML and see
mistakes/improvements that can be made, please let me know. The Blast
class diagram is shown in
Figure [1](#fig:blastrecord){reference-type="ref"
reference="fig:blastrecord"}.

![Class diagram for the Blast Record class representing all of the info
in a BLAST report](images/BlastRecord.png){#fig:blastrecord width="80%"}

The PSIBlast record object is similar, but has support for the rounds
that are used in the iteration steps of PSIBlast. The class diagram for
PSIBlast is shown in
Figure [2](#fig:psiblastrecord){reference-type="ref"
reference="fig:psiblastrecord"}.

Notice the figure labels and caption text is preserved. But not for RST output:

$ pandoc -f latex -t rst snippet.tex --verbose
Here are my attempts at UML class diagrams for the ``Blast`` and
``PSIBlast`` record classes. If you are good at UML and see
mistakes/improvements that can be made, please let me know. The Blast
https://docutils.sourceforge.io/docs/ref/rst/directives.html#figureclass diagram is shown in Figure `1 <#fig:blastrecord>`__.

.. figure:: images/BlastRecord.png
   :alt:
   :width: 80.0%

The PSIBlast record object is similar, but has support for the rounds
that are used in the iteration steps of PSIBlast. The class diagram for
PSIBlast is shown in Figure `2 <#fig:psiblastrecord>`__.

.. figure:: images/PSIBlastRecord.png
   :alt:
   :width: 80.0%

Notice the figures are missing their captions and name (so the references fail).

I was expecting the figure caption to be used as the caption, with the label used for :name: as per:

https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure
https://docutils.sourceforge.io/docs/ref/rst/directives.html#common-options

Note #8743 covers the :alt: field, fixed in pandoc 3.1.4.

Issue #8871 is somewhat related (mixing the alt-text and caption)

Pandoc version?

This is using the latest pandoc available via conda for Linux (so a revision behind the current release 3.1.4), run under Ubuntu on WSL under Windows 11:

$ pandoc --version
pandoc 3.1.3
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/pcock/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
@peterjc peterjc added the bug label Jun 30, 2023
@peterjc
Copy link
Author

peterjc commented Jul 12, 2023

This appears to have been working better under pandoc 2.14.1 and 2.19.2, here run under macOS:

$ pandoc -f latex -t rst snippet.tex --verbose
ere are my attempts at UML class diagrams for the ``Blast`` and
``PSIBlast`` record classes. If you are good at UML and see
mistakes/improvements that can be made, please let me know. The Blast
class diagram is shown in Figure `1 <#fig:blastrecord>`__.

.. figure:: images/BlastRecord.png
   :alt: Class diagram for the Blast Record class representing all of
   the info in a BLAST report
   :name: fig:blastrecord
   :width: 80.0%

   Class diagram for the Blast Record class representing all of the info
   in a BLAST report

The PSIBlast record object is similar, but has support for the rounds
that are used in the iteration steps of PSIBlast. The class diagram for
PSIBlast is shown in Figure `2 <#fig:psiblastrecord>`__.

.. figure:: images/PSIBlastRecord.png
   :alt: Class diagram for the PSIBlast Record class.
   :name: fig:psiblastrecord
   :width: 80.0%

   Class diagram for the PSIBlast Record class.

It was noted in the comments on #8743 that the loss of the :alt: field was a regression too, possibly the same root cause?

@peterjc
Copy link
Author

peterjc commented Jul 12, 2023

Thank you - I'll retest as soon as I can easily install this.

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

1 participant