public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Ash Wiseth <ash.wiseth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: LaTeX reader: Issue when `\label` and `\caption` separated
Date: Wed, 28 Dec 2022 08:22:08 -0800 (PST)	[thread overview]
Message-ID: <b31d021f-ce8b-4c2e-b2bd-ad9d65a68606n@googlegroups.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 3073 bytes --]

Hi,

I use to Pandoc to convert a large number of LaTeX articles into Markdown, 
with the original LaTeX articles all from different authors with their own 
idiosyncratic styles. I've been trying to narrow down some of the 
conversion issues that have cropped up, and I noticed that the LaTeX reader 
seems to be very particular about how elements in float (table, figure) 
environments are ordered.

For LaTeX, `\label` normally has to be either inside `\caption` or after 
`\caption`. As far as I know, however, there is no requirement that 
`\label` (if appearing after and not inside) appear *immediately* after 
`\caption`. For example, I can get the following (with `\label` *not* immediately 
after `\caption`) to compile without any errors or warnings:

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}

\section{Introduction}

 The model is shown in Figure \ref{fig:sensPlot}.

    \begin{figure}
        \caption{Dependence on Prior Settings}
        \includegraphics[width=0.7\textwidth]{figures/sensPlot-1.pdf}
        \label{fig:sensPlot}
    \end{figure}

\end{document}
```

However, when I run Pandoc 2.19.2 to convert this to Markdown, the figure 
is not processed correctly (the cross-reference appears as [fig:sensPlot] 
instead of 1, and the caption disappears):

```
# Introduction

The model is shown in Figure 
[\[fig:sensPlot\]](#fig:sensPlot){reference-type="ref" 
reference="fig:sensPlot"}.

![image](figures/sensPlot-1.pdf){width="70%"} []{#fig:sensPlot 
label="fig:sensPlot"}
```

Running `pandoc -t native`, it looks like the label is getting separated 
from the rest of the figure:

```
[ Header
    1 ( "introduction" , [] , [] ) [ Str "Introduction" ]
, Para
    [ Str "The"
    , Space
    , Str "model"
    , Space
    , Str "is"
    , Space
    , Str "shown"
    , Space
    , Str "in"
    , Space
    , Str "Figure"
    , Space
    , Link
        ( ""
        , []
        , [ ( "reference-type" , "ref" )
          , ( "reference" , "fig:sensPlot" )
          ]
        )
        [ Str "[fig:sensPlot]" ]
        ( "#fig:sensPlot" , "" )
    , Str "."
    ]
, Para
    [ Image
        ( "" , [] , [ ( "width" , "70%" ) ] )
        [ Str "image" ]
        ( "figures/sensPlot-1.pdf" , "" )
    , SoftBreak
    , Span
        ( "fig:sensPlot" , [] , [ ( "label" , "fig:sensPlot" ) ] )
        []
    ]
]
```

Note that this can be fixed by (1) moving `\label` into `\caption`, (2) 
switching `\includegraphics` and `\label`, or (3) switching `\caption` and 
`\includegraphics`. So it definitely seems like an order issue.

What am I missing? Is this a bug?

Thank you in advance.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b31d021f-ce8b-4c2e-b2bd-ad9d65a68606n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4401 bytes --]

                 reply	other threads:[~2022-12-28 16:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b31d021f-ce8b-4c2e-b2bd-ad9d65a68606n@googlegroups.com \
    --to=ash.wiseth-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).