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

org-reader: Parse image and table label #2999

Closed
michelk opened this issue Jun 26, 2016 · 17 comments
Closed

org-reader: Parse image and table label #2999

michelk opened this issue Jun 26, 2016 · 17 comments

Comments

@michelk
Copy link

michelk commented Jun 26, 2016

  • The org-reader does not read the image and table label.
  • Cross-references are not rendered correctly.

cc @tarleb

Minimal example

Org-file:

As illustrated in figure [[fig:myfig]], ... and listed in table [[tab:mytab]]

#+CAPTION: My figure.
#+LABEL: fig:myfig
[[blub.png]]


#+CAPTION: My table.
#+LABEL: tab:mytab
 | Name | Value |
 |------+-------|
 | Uno  |     1 |
 | Due  |     2 |

Expected Latex

As illustrated in figure \ref{fig:myfig}, \ldots{} and listed in table
\ref{tab:mytab}

\begin{figure}[htbp]
\centering
\includegraphics{blub.png}
\caption{My figure}
\label{fig:myfig}
\end{figure}

\begin{longtable}[]{@{}ll@{}}
\caption{My table}\label{tab:mytab}\tabularnewline
\toprule
Name & Value\tabularnewline
\midrule
\endfirsthead
\toprule
Name & Value\tabularnewline
\midrule
\endhead
Uno & 1\tabularnewline
Due & 2\tabularnewline
\bottomrule
\end{longtable}

Actual latex

As illustrated in figure \url{fig:myfig}, \ldots{} and listed in table
\url{tab:mytab}

\begin{figure}[htbp]
\centering
\includegraphics{blub.png}
\caption{My figure}
\end{figure}

\begin{longtable}[]{@{}ll@{}}
\caption{My table}\tabularnewline
\toprule
Name & Value\tabularnewline
\midrule
\endfirsthead
\toprule
Name & Value\tabularnewline
\midrule
\endhead
Uno & 1\tabularnewline
Due & 2\tabularnewline
\bottomrule
\end{longtable}
tarleb added a commit to tarleb/pandoc that referenced this issue Jun 26, 2016
Figure labels given as `#+LABEL: thelabel` are used as the ID of the
respective image.  This allows e.g. the LaTeX to add proper `\label`
markup.

This fixes half of jgm#2496 and jgm#2999.
@tarleb
Copy link
Collaborator

tarleb commented Jun 26, 2016

Thanks for the report. This is a duplicate of #2496, though info in that threat is obsolete.

PR #3001 adds labels for figures. Labeling tables is not possible at the moment. (@jgm, please correct me if I'm wrong.)

@jgm
Copy link
Owner

jgm commented Jun 27, 2016

Closing in favor of #2496

@jgm jgm closed this as completed Jun 27, 2016
@michelk
Copy link
Author

michelk commented Oct 5, 2016

Org-mode

As seen in fig. [[fig:1]]

Translates to latex:

As seen in fig. \url{fig:1}

I would expect

As seen in fig. \ref{fig:1}

Is it possible to fix this in the org-reader?

@tarleb
Copy link
Collaborator

tarleb commented Oct 5, 2016

Unfortunately this is not a simple change. It requires, among other things, changes to pandoc's internal document model, which is always a lot of work. See also #1299.

@jgm
Copy link
Owner

jgm commented Oct 6, 2016

I suppose the org reader could keep an internal count of
figure numbers, and insert the figure number as the
link text here. That wouldn't require any changes to
pandoc-types at all.

+++ Albert Krewinkel [Oct 05 16 11:12 ]:

Unfortunately this is not a simple change. It requires, among other
things, changes to pandoc's internal document model, which is always a
lot of work. See also [1]#1299.


You are receiving this because you modified the open/close state.
Reply to this email directly, [2]view it on GitHub, or [3]mute the
thread.

References

  1. Support for anchors #1299
  2. org-reader: Parse image and table label #2999 (comment)
  3. https://github.com/notifications/unsubscribe-auth/AAAL5NpKaYfXJtkx0XMWIkAuNE0MLU47ks5qw-iRgaJpZM4I-hHA

@tarleb
Copy link
Collaborator

tarleb commented Oct 6, 2016

I'm probably being dense here again, but I don't see how this would work. From a quick grep it seems to me that the LaTeX writer won't output \ref no matter what. Am I misunderstanding something?

@michelk
Copy link
Author

michelk commented Oct 7, 2016

I guess John means, that the org-reader could parse [[fig:1]] as a literal 1.

But this approach fails for example when outputting a LaTeX report, where this could be 1.1

@michelk
Copy link
Author

michelk commented Oct 7, 2016

Meanwhile I would be happy with this workaround.

@jgm
Copy link
Owner

jgm commented Oct 9, 2016

+++ Michel Kuhlmann [Oct 06 16 23:19 ]:

I guess John means, that the org-reader could parse [[fig:1]] as a
literal 1.

But this approach fails for example when outputting a LaTeX report,
where this could be 1.1

Correct, but this is the best we could achieve with just
changes in the org reader. A better solution would require
a complete (and probably complex) label/reference system in
pandoc.

@michelk
Copy link
Author

michelk commented Aug 3, 2017

Any update with the numbering workaround?

@michelk
Copy link
Author

michelk commented Aug 3, 2017

Or would you recommend a lua-filter?

@tarleb
Copy link
Collaborator

tarleb commented Aug 5, 2017

Apologies, I'm currently short on time and cannot work on this right now.

I believe a filter-based solution should be possible. Allowing lua filters to use a hierarchicalized version of the AST would probably help here (and would make the solution for tarleb/pandoc-org-presentations#1 much simpler).

@michelk
Copy link
Author

michelk commented Aug 6, 2022

Is there any update with table-labels in the org-mode reader?

 #+CAPTION:  My caption.
 #+LABEL: tab:mytable
|      Year | Topic                                    |
|-----------+--------------------------------------|

\label{tab:mytable} still doesn't show up in latex.

@tarleb
Copy link
Collaborator

tarleb commented Aug 6, 2022

Looks like a shortcoming of the LaTeX writer. Please open a new issue for this.

@michelk
Copy link
Author

michelk commented Aug 6, 2022

I'm unsure, what to describe in the new issue. Should I just reference to this issue?

@michelk
Copy link
Author

michelk commented Aug 7, 2022

Another question (maybe off-topic here):

How could I pass image-width to LaTeX? ATTR_HTML or ATTR_LATEX doesn't seem to work.

#+CAPTION: My figure.
#+LABEL: fig:myfig
#+ATTR_HTML: :width \textwidth
[[blub.png]]

@tarleb
Copy link
Collaborator

tarleb commented Aug 7, 2022

The pandoc-discuss mailing list would probably be a better place for these questions.

Re image width: use #+ATTR_HTML: :width 100%

Re labels on LaTeX tables: I've opened #8219 to keep track of the issue.

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

No branches or pull requests

3 participants