From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28909 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Leena Murgai Newsgroups: gmane.text.pandoc Subject: Re: Equation labels/references when converting from latex to markdown/other Date: Fri, 23 Jul 2021 16:06:30 -0700 (PDT) Message-ID: <5e86f41a-1515-4843-a4bc-2cb2ef1d63dan@googlegroups.com> References: <733e0d35-b1c4-4380-bf9f-7d6523c55162n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2246_1003835106.1627081590818" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23333"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCIMDCM26AARB6EW5WDQMGQEDBQKIPY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jul 24 01:06:35 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f59.google.com ([209.85.161.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m74FW-0005up-Cv for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 24 Jul 2021 01:06:34 +0200 Original-Received: by mail-oo1-f59.google.com with SMTP id t62-20020a4a3e410000b0290263d7da47fbsf1919656oot.17 for ; Fri, 23 Jul 2021 16:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=Apcm06sgGln74m9bDKNSU058jSc3xwOseGp0v1AQC2U=; b=pQwQTQLO5xzaFCHWAhE6F6CN0Dg22eZgMoUGQFnjyS56zXZsGsyviZK+2qsl2KUeSA NrQxzeHRoR/xMcWT/2vR0CizdxhbskGrmrs1dFdQWKFcMjhSfCeBe5YO/Yy95Pb/x1T2 VbKkxZsXxJ8qpxqc0LPdmAyXj7sImVWeYcY6aSXjiwOLknV2SreG+7UI/4FFqo6gAdjS fR5uQNemRwacAjoK15DpiHKeS581vfm56+Gb896BNhs11cSYP3qQwkBfGD1FVWwRxGkj SJMFcu73COajzoHQ8QLuFc+z+G1EyHv8p4wKvLq7xMna7IAASClu2IpEx12oTCfE2ZLB 5h/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=Apcm06sgGln74m9bDKNSU058jSc3xwOseGp0v1AQC2U=; b=M58uszQKmzYmt6U42h3HrsTBA1o+1hHX6Jl2yLJywZDIyX1p8+b1T11m1xk3u7eP2O JakO8KJmTILjZF8N9jCEOdRxab9usCa8u1u5ft9NOJ2mYMG/BOP2t1/jCYrpkIVnvhc7 HpTpuZdYmonMNbIlMNGIlwfo1rtg30UsTXWG282MQM/es6dNiEZEoL6kPm7PXgWbDAXF XlUnczimsdltLmJInsEwopS72miJWtqFFi4LAAfORpLNj8plD2HFT7EQVf4mcDBolKk3 hxGFiDPuxtqW2bOmOctfW3kdO1yAxW7KaEfnw1/NqtoaBZDGAIRYSQklIzgtDrmuEjC9 yroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=Apcm06sgGln74m9bDKNSU058jSc3xwOseGp0v1AQC2U=; b=bJeDNPmorQlrTPFf7e0dvcJOGTLEWY+ZqubhgDQz+BAC+dV2YrLinSkFfdlSV3CBUW Nx9P0ffQ5BhR9ktnYP08wLIv4a5ULGOZ17fI6PcOqsIAOGzt1leL0GyORuKRiRk4PIV+ w/XbmpwF2oNBflDdAfqRyhBf0ygcna9/i67dvIN3AM8D2JcgTm71Cal12JoiF6zd2ko/ 4fn1Aq0KB9BdpgCbp4TQKBwEqNVQxJjDz3dvNRmKPbXHccQUoAHEL5T8Sc8XD8ySr6oN CpkOMh2TZOVe6PCZHEwgIy2HBU9gKQJyPDGnIp1efRXXO8kPwByeU+49HBl0obKbRZ2H RIGQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531pJGFchZiQNazEeHEzaBqrO2RoAcuOx9fbmoCZwB5SVdsJO6pj kAe+7sYWU72qbOgdtCYHh+c= X-Google-Smtp-Source: ABdhPJw/n20YnjbQlTQbKub8ysCnKQyfwe29+mYXX3hMAj0lwmHZndLG4pEX084sqMvvjoRYaq0Jrg== X-Received: by 2002:a9d:2c61:: with SMTP id f88mr4605663otb.62.1627081593420; Fri, 23 Jul 2021 16:06:33 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:d0b0:: with SMTP id t16ls766178oor.0.gmail; Fri, 23 Jul 2021 16:06:31 -0700 (PDT) X-Received: by 2002:a4a:55cd:: with SMTP id e196mr4090736oob.2.1627081591564; Fri, 23 Jul 2021 16:06:31 -0700 (PDT) In-Reply-To: X-Original-Sender: leenamurgai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:28909 Archived-At: ------=_Part_2246_1003835106.1627081590818 Content-Type: multipart/alternative; boundary="----=_Part_2247_940221859.1627081590818" ------=_Part_2247_940221859.1627081590818 Content-Type: text/plain; charset="UTF-8" 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 . Here's the HTML output in each case: 1. \label{eq:label} after \begin{equation}: \label{eq:label}equation 2. \label{eq:label} after equation: equation\label{eq:label} 3. \label{eq:label} after \end{equation}: Note that this will break the LaTeX code equation[eq:label] 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
equation (chap#.value{ eq:label})
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 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 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/5e86f41a-1515-4843-a4bc-2cb2ef1d63dan%40googlegroups.com. ------=_Part_2247_940221859.1627081590818 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 a= t what pandoc-crossref expects to find in the markdown. 
LaTeX equation format:
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 t= o see if it made a difference to the output HTML since pandoc-crossref expects= to find the label after the equation environment. Here's the HTML outp= ut in each case:

1. eq:label} after \begin{equation}:

=   <span class=3D"math display">\label= {eq:label}equation</span>
=

2. \label{eq:label} after equation:

  <span class=3D"math display">equati= on\label{eq:label}</span>

3. \label{= eq:label} after \end{equation}: Note that this will break the LaTeX code<= /div>

  <span cl= ass=3D"math display">equation</span><span>[eq:label]</span>

So, none of the above seem to give pandoc-cro= ssref 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 o= utput (if I could get it to work) would be great. My quick and dirty approa= ch (to get something like what LaTeX gives) would be to put the equation an= d its label in a table row. Something like

<div>
<table width=3D100% style=3D"border: none;">
<= font face=3D"Courier New"><tr>
<td style=3D"text-align: center; border: none;"><span id=3D"= eq:label" class=3D"math display">equation= </span></td>
<td= style=3D"text-align: right; border: none; width: 5%;">(chap#.value{eq:label})</td= >
</tr>
</table>
</div>

I'm open t= o suggestions if hard coding 5% for the label width seems like a bad idea o= r some such.

Thanks,
Leena


<= div>
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...@gm= ail.com> 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 a= nd \ref=20
> for equations don't work. I'd be super grateful for any ad= vice you could=20
> 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",&quo= t;ref"),("reference","foo")]) [Str=20
>> "[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 c= an
>> show you how to do it.
>>
>> Ian Price <ianpr= ...@gmail.com> writes:
>>
>> > Hello,
>> > My university is looking into the options for converting = various notes,=20
>> > exercises sheets, presentations, etc. from latex generate= d pdf into a=20
>> more=20
>> > accessible format. This basically means converting to htm= l + mathjax=20
>> > because this tends to work better for screen readers. Con= verting beamer=20
>> > seems to be impossible, but for notes pandoc (and some ot= hers like=20
>> latexml)=20
>> > is generally giving good output, however the major issue = is cross=20
>> > referencing between text and maths blocks.
>> >
>> > In short, mathjax can handle internal links from maths bl= ocks to other=20
>> > maths blocks, and pandoc can handle links to other parts = of pandoc=20
>> > documents, except when a document makes specific referenc= e to an=20
>> equation.
>> > For example, suppose we have the following mwe.tex cut ou= t from some=20
>> > electromagnetism notes
>> > ---
>> > \documentclass[12pt]{article}=20
>> > \begin{document}=20
>> > \begin{equation}=20
>> > J \equiv \frac{dI}{da_{\perp}} =3D \rho v.=20
>> > \label{volume-current-density}=20
>> > \end{equation}=20
>> > The total current crossing a surface $S$ can be calculate= d by=20
>> integrating=20
>> > Eq. (\ref{volume-current-density}):=20
>> > \end{document}
>> > ---
>> > When converted to markdown, we get the following
>> > ---
>> > $$J \equiv \frac{dI}{da_{\perp}} =3D \rho v.=20
>> > \label{volume-current-density}$$=20
>> >=20
>> > The total current crossing a surface $S$ can be calculate= d by=20
>> > integrating Eq.=20
>> >=20
>> ([\[volume-current-density\]](#volume-current-density){referen= ce-type=3D"ref"=20
>> > reference=3D"volume-current-density"}):
>> > ---
>> > The link to the label volume-current-density is clearly b= roken and when=20
>> I=20
>> > get my html file it does nothing in particular.
>> >
>> > One solution I've seen is to convert the label refere= nces to the syntax=20
>> > used by, e.g., pandoc-crossref, but this involves me edit= ing the=20
>> markdown=20
>> > by hand. Is there an automatic way to convert these?=20
>> >
>> > --=20
>> > You received this message because you are subscribed to t= he Google=20
>> Groups "pandoc-discuss" group.
>> > To unsubscribe from this group and stop receiving emails = from it, send=20
>> an email to pandoc-= discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
>> > To view this discussion on the web visit=20
>> https://groups= .google.com/d/msgid/pandoc-discuss/733e0d35-b1c4-4380-bf9f-7d6523c55162n%40= googlegroups.com
>> .
>>
>
> --=20
> 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..= .@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d= 3a1fa02-147c-45c2-8ee1-462db48baa44n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/5e86f41a-1515-4843-a4bc-2cb2ef1d63dan%40googlegroups.= com.
------=_Part_2247_940221859.1627081590818-- ------=_Part_2246_1003835106.1627081590818--