public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Leena Murgai <leenamurgai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Equation labels/references when converting from latex to markdown/other
Date: Fri, 23 Jul 2021 16:22:24 -0700 (PDT)	[thread overview]
Message-ID: <7662f9b4-f4eb-45bb-bc0d-04d82bdf9505n@googlegroups.com> (raw)
In-Reply-To: <5e86f41a-1515-4843-a4bc-2cb2ef1d63dan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


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

Oh and
\ref{eq:label}
in LaTeX should give
<a href ="#eq:label"data-reference-type="ref" data-reference="eq:label">
chap#.value(eq:label)</a>
in HTML.
On Friday, 23 July 2021 at 16:06:31 UTC-7 Leena Murgai wrote:

> Thanks for the reply John.
>
> I've been playing around with an equation in LaTeX and seeing what comes 
> out in HTML5 and also looking at what pandoc-crossref expects to find in 
> the markdown. 
>
> LaTeX equation format:
>   \begin{equation} \label{eq:label}
>   equation
>   \end{equation}
> Note: \label{eq:label} must be inside the equation environment, above is 
> how I do it, but equally one can place the label after equation.
>
> I tried moving label around in my LaTeX to see if it made a difference to 
> the output HTML since pandoc-crossref expects to find the label after the 
> equation environment 
> <http://lierdakil.github.io/pandoc-crossref/#equation-labels>. Here's the 
> HTML output in each case:
>
> 1. \label{eq:label} after \begin{equation}:
>
>   <span class="math display">\label{eq:label}equation</span>
>
> 2. \label{eq:label} after equation:
>
>   <span class="math display">equation\label{eq:label}</span>
>
> 3. \label{eq:label} after \end{equation}: Note that this will break the 
> LaTeX code
>
>   <span class="math display">equation</span><span>[eq:label]</span>
>
> So, none of the above seem to give pandoc-crossref what it needs. 
> Honestly, I'm not massively familiar with HTML and css - just figuring it 
> out as I go. I imagine whatever pandoc-crossref would output (if I could 
> get it to work) would be great. My quick and dirty approach (to get 
> something like what LaTeX gives) would be to put the equation and its label 
> in a table row. Something like
>
> <div>
> <table width=100% style="border: none;">
> <tr>
> <td style="text-align: center; border: none;"><span id="eq:label" 
> class="math display">equation</span></td>
> <td style="text-align: right; border: none; width: 5%;">(chap#.value{
> eq:label})</td>
> </tr>
> </table>
> </div>
>
> I'm open to suggestions if hard coding 5% for the label width seems like a 
> bad idea or some such.
>
> Thanks,
> Leena
>
>
>
> On Wednesday, 21 July 2021 at 22:24:47 UTC-7 John MacFarlane wrote:
>
>>
>> As I said: 
>>
>> Just let us know what you want to appear in the HTML, and we can 
>> show you how to do it. 
>>
>>
>>
>> Leena Murgai <leena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>>
>> > Hi John, 
>> > 
>> > Can you clarify your work around here? I wasn't able to follow. 
>> > 
>> > I have a similar problem converting from LaTeX to HTML5 - \label and 
>> \ref 
>> > for equations don't work. I'd be super grateful for any advice you 
>> could 
>> > offer. 
>> > 
>> > Thanks! 
>> > Leena 
>> > 
>> > On Tuesday, 29 June 2021 at 11:23:40 UTC-7 John MacFarlane wrote: 
>> > 
>> >> 
>> >> This isn't yet supported, really. But you might be able to 
>> >> work around it. 
>> >> 
>> >> Note: 
>> >> 
>> >> % pandoc -f latex -t native 
>> >> \ref{foo} 
>> >> ^D 
>> >> [Para [Link ("",[],[("reference-type","ref"),("reference","foo")]) 
>> [Str 
>> >> "[foo]"] ("#foo","")]] 
>> >> 
>> >> So when pandoc parses \ref{foo}, it doesn't just create a string 
>> >> [foo]; it creates a link with attributes. You could use a lua 
>> >> filter to turn this into something that mathjax can consume 
>> >> (raw tex, I would imagine). 
>> >> 
>> >> Just let us know what you want to appear in the HTML, and we can 
>> >> show you how to do it. 
>> >> 
>> >> Ian Price <ianpr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>> >> 
>> >> > Hello, 
>> >> > My university is looking into the options for converting various 
>> notes, 
>> >> > exercises sheets, presentations, etc. from latex generated pdf into 
>> a 
>> >> more 
>> >> > accessible format. This basically means converting to html + mathjax 
>> >> > because this tends to work better for screen readers. Converting 
>> beamer 
>> >> > seems to be impossible, but for notes pandoc (and some others like 
>> >> latexml) 
>> >> > is generally giving good output, however the major issue is cross 
>> >> > referencing between text and maths blocks. 
>> >> > 
>> >> > In short, mathjax can handle internal links from maths blocks to 
>> other 
>> >> > maths blocks, and pandoc can handle links to other parts of pandoc 
>> >> > documents, except when a document makes specific reference to an 
>> >> equation. 
>> >> > For example, suppose we have the following mwe.tex cut out from some 
>> >> > electromagnetism notes 
>> >> > --- 
>> >> > \documentclass[12pt]{article} 
>> >> > \begin{document} 
>> >> > \begin{equation} 
>> >> > J \equiv \frac{dI}{da_{\perp}} = \rho v. 
>> >> > \label{volume-current-density} 
>> >> > \end{equation} 
>> >> > The total current crossing a surface $S$ can be calculated by 
>> >> integrating 
>> >> > Eq. (\ref{volume-current-density}): 
>> >> > \end{document} 
>> >> > --- 
>> >> > When converted to markdown, we get the following 
>> >> > --- 
>> >> > $$J \equiv \frac{dI}{da_{\perp}} = \rho v. 
>> >> > \label{volume-current-density}$$ 
>> >> > 
>> >> > The total current crossing a surface $S$ can be calculated by 
>> >> > integrating Eq. 
>> >> > 
>> >> 
>> ([\[volume-current-density\]](#volume-current-density){reference-type="ref" 
>> >> > reference="volume-current-density"}): 
>> >> > --- 
>> >> > The link to the label volume-current-density is clearly broken and 
>> when 
>> >> I 
>> >> > get my html file it does nothing in particular. 
>> >> > 
>> >> > One solution I've seen is to convert the label references to the 
>> syntax 
>> >> > used by, e.g., pandoc-crossref, but this involves me editing the 
>> >> markdown 
>> >> > by hand. Is there an automatic way to convert these? 
>> >> > 
>> >> > -- 
>> >> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> >> > To view this discussion on the web visit 
>> >> 
>> https://groups.google.com/d/msgid/pandoc-discuss/733e0d35-b1c4-4380-bf9f-7d6523c55162n%40googlegroups.com 
>> >> . 
>> >> 
>> > 
>> > -- 
>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/d3a1fa02-147c-45c2-8ee1-462db48baa44n%40googlegroups.com. 
>>
>>
>

-- 
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/7662f9b4-f4eb-45bb-bc0d-04d82bdf9505n%40googlegroups.com.

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

  parent reply	other threads:[~2021-07-23 23:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 18:06 Ian Price
     [not found] ` <733e0d35-b1c4-4380-bf9f-7d6523c55162n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-06-29 18:23   ` John MacFarlane
     [not found]     ` <m25yxwleck.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-07-22  3:44       ` Leena Murgai
     [not found]         ` <d3a1fa02-147c-45c2-8ee1-462db48baa44n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-07-22  5:24           ` John MacFarlane
     [not found]             ` <m2v9523oq7.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-07-23 23:06               ` Leena Murgai
     [not found]                 ` <5e86f41a-1515-4843-a4bc-2cb2ef1d63dan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-07-23 23:22                   ` Leena Murgai [this message]
     [not found]                     ` <7662f9b4-f4eb-45bb-bc0d-04d82bdf9505n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-07-24  1:36                       ` Leena Murgai
     [not found]                         ` <0a0f727f-8001-40f9-84e6-4e60574b2af1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-07-28 20:17                           ` Leena Murgai

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=7662f9b4-f4eb-45bb-bc0d-04d82bdf9505n@googlegroups.com \
    --to=leenamurgai-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).