From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32327 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Julien Dutant Newsgroups: gmane.text.pandoc Subject: Re: Including SVGs with LaTeX math in Pandoc? Date: Sun, 12 Mar 2023 17:59:15 -0700 (PDT) Message-ID: <3296c082-c030-4075-94a7-fa34aed7e3c1n@googlegroups.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_4_2004024274.1678669155558" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21715"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBC5Y3356IYIOJ2VZUADBUBC5NX4EK-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Mar 13 01:59:20 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qt1-f188.google.com ([209.85.160.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pbWX2-0005RI-6e for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 13 Mar 2023 01:59:20 +0100 Original-Received: by mail-qt1-f188.google.com with SMTP id k13-20020ac8074d000000b003bfd04a3cbcsf6056177qth.16 for ; Sun, 12 Mar 2023 17:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1678669159; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=gemC7fC5phhdFQyWFxrFpe+KNOB7BCdsQs7yf5GvCZ4=; b=eYGDRJ8m4oePDpOdwO23AG5jZZoavDqczfxJqm3qhuIxooWL5KVwyxeTzfX7j7q5c1 lrXJpnAzSQoS7pouoIp+zMxaEDnWwfL3RQ66Vkh5mgKUBz7Axmm49Qv3hO0M2cgrz7x1 M3AQCe+9De7sRFNbZi9eOap67UxkefjAfze9yN+EDyzuIyQS1ymAD/Iaf5sQBfQxljLY b0aP5lvJK4/vk4t7z1r22ZMalUrczl1iC1q8KojcoHdOsw+3yb6GrWvvkDyC1hu0zzir R1FNyk3liPtLbOrIwxPN4bP77yLGn4lxbWXQx3d+MWRxNBYZFpc/lEJ4KXcE9PgIrQgZ XFYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678669159; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=gemC7fC5phhdFQyWFxrFpe+KNOB7BCdsQs7yf5GvCZ4=; b=oTM+Rj6st0cB3Mc0+Tfgs1bku+bXiDgHgx1NG/zRnJ5BWJrVJ9JYlSpFDcfyiXYhmP uu0VbzppZ+2XxEAeIC8wDHBIA71iD5DckDgWOTEYipgwG90fHrrraxN9jZSNfzvUtYF1 mW4P45PS4V9/wfSP2FuGqNBStT5Hj73is3XLpF2HVT7zy6SFruze3pkwUiCzwNS9eipJ BI7qaMQCAYqH1/65ScYYF6U/oev+WJ16V4Z9Xy/5l8fIJynvRMq8ZM06cRDyyoGcmIo9 umagnomCCzCKD/onChPurcND0LYO0Qu3UemKTV/VB6M9KXNIqGO5bdCsQ0zXDeEd3xnI oFSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678669159; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=gemC7fC5phhdFQyWFxrFpe+KNOB7BCdsQs7yf5GvCZ4=; b=XRtoo47c+1eeA5q51jE8FYEVdUADZxEfhnGI41dafqfQAMw/s58E2QvXUGx9pVXFMq w7smoqVkf1cCKjeZV16SS36GG/+9M399sZoNGcFUlAXSfSw+reCV3HEwYt2sfy4fEq5A SR33PiDU/nmDYrVPENwLKADJE4tXCJKpo6bpuW0xE94Bhy9MJVyrBvcsNaGuHMMR/YGM wsA+JwKfBRURa7qDzDFTbiijo3qDvx6H7xutXqwpn9p2oOfFXA88KKyHt6mmecyUDAvY BHVGT1jN0hvS0NRO1bKqjccQmHJWMqWq/ZjwRCK/bN4UsgS1F+paLQVhf2WULRevmrOY Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKWTyudInajE3eRe/NSQ1LvNL4qO9Y5RLkZx3y10hBctxeUJFK4K u+T1fqlxPRX3G0NidIzyphA= X-Google-Smtp-Source: AK7set9svFkbf3HhIVx8FJbnsvYTVV0wPtQSOwC2yWHfb7TLv6I+8q1QfTFvj71sBfEYVsjy2I/4qg== X-Received: by 2002:ac8:93:0:b0:3b7:fda5:1cb9 with SMTP id c19-20020ac80093000000b003b7fda51cb9mr8284987qtg.2.1678669159149; Sun, 12 Mar 2023 17:59:19 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6214:2e48:b0:56e:9b27:727c with SMTP id my8-20020a0562142e4800b0056e9b27727cls8570696qvb.0.-pod-prod-gmail; Sun, 12 Mar 2023 17:59:16 -0700 (PDT) X-Received: by 2002:a05:6214:b21:b0:56f:2c51:ff89 with SMTP id w1-20020a0562140b2100b0056f2c51ff89mr1505392qvj.5.1678669156257; Sun, 12 Mar 2023 17:59:16 -0700 (PDT) In-Reply-To: X-Original-Sender: julien.dutant-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:32327 Archived-At: ------=_Part_4_2004024274.1678669155558 Content-Type: multipart/alternative; boundary="----=_Part_5_144434501.1678669155558" ------=_Part_5_144434501.1678669155558 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Perhaps one of these: method 1, without external conversion. Load the LaTeX package in markdown,= =20 insert the raw LaTeX command: ``` markdown --- header-includes: ``` {=3Dlatex} \usepackage{svg} ``` --- See illustration below: \includesvg[scale=3D1.0]{idea.svg} ``` Downside: the image only shows in LaTeX/PDF output. You could use a filter= =20 that allows you to hide/show bits depending on output formats, but then you= =20 might as well use Bastien's filter. method 2, external conversion: as you've done, but you should use the=20 standalone document class (assuming it doesn't conflict with the svg=20 package. It crops documents to the size of the image. See=20 https://ctan.org/pkg/standalone=20 Best, J On Monday, March 6, 2023 at 3:53:48=E2=80=AFPM UTC A A wrote: > I'd rather not write any filters for this, and convert to PDF or another= =20 > format externally, then embed in markdown. Is there perhaps a way to do= =20 > that? > > On Mon, 6 Mar 2023 at 16:46, Bastien DUMONT wrote= : > >> You can include the command directly in the resulting LaTeX document.=20 >> This filter should do the job: >> >> ``` >> function Image(image) >> local file =3D image.src >> if FORMAT =3D=3D 'latex' and string.match(file, '%.svg$') then >> return pandoc.RawInline('latex', '\\includesvg[scale=3D1.0]{' .. fil= e=20 >> .. '}') >> end >> end >> ``` >> >> >> Le Monday 06 March 2023 =C3=A0 04:11:37PM, A A a =C3=A9crit : >> > I=E2=80=99d like to include SVG graphics in my LaTeX document using pa= ndoc. I >> > understand this is currently [1]not supported so I have resorted to th= e=20 >> idea of >> > performing the SVG to PDF conversion externally and then including in = my >> > markdown using something like this: >> >=20 >> > ![whee](foo.pdf) >> >=20 >> > I would prefer not to do this conversion using raw inkscape because th= e=20 >> svg >> > package in LaTeX has the added advantage of rendering LaTeX math withi= n=20 >> the >> > figure if it encounters LaTeX math in the SVG. This won=E2=80=99t happ= en if I=20 >> only use >> > inkscape. >> >=20 >> > Unfortunately, I haven=E2=80=99t found a way to ensure that the result= ing PDF is >> > cropped to the extents of the image after doing a LaTeX compilation. F= or >> > example: >> >=20 >> > \documentclass{article} >> >=20 >> > \usepackage{svg} >> >=20 >> > \begin{document} >> > \includesvg[scale=3D1.0]{idea.svg} >> >=20 >> > \end{document} >> >=20 >> > will compile as a full A4 sized page with page number. If I then=20 >> include it in >> > my markdown as ![idea](idea.pdf) I=E2=80=99d get the whole page as my = =E2=80=9Cfigure=E2=80=9D=20 >> and not >> > only the SVG. >> >=20 >> > How can include SVGs with LaTeX math in Pandoc ? >> >=20 >> > -- >> > You received this message because you are subscribed to the Google=20 >> Groups >> > "pandoc-discuss" group. >> > To unsubscribe from this group and stop receiving emails from it, send= =20 >> an email >> > to [2]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit [3] >> https://groups.google.com/d/msgid/ >> > pandoc-discuss/ >> > CAMwawgPKcXu-CapB6d_vSWc7%3DvfA_sQSzFnnv4nGBurq6%2BMkEw% >> 40mail.gmail.com. >> >=20 >> > References: >> >=20 >> > [1] https://github.com/jgm/pandoc/issues/265 >> > [2] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >> > [3]=20 >> https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgPKcXu-CapB6d_vSW= c7%3DvfA_sQSzFnnv4nGBurq6%2BMkEw%40mail.gmail.com?utm_medium=3Demail&utm_so= urce=3Dfooter >> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group. >> > To unsubscribe from this group and stop receiving emails from it, send an= =20 >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit=20 >> https://groups.google.com/d/msgid/pandoc-discuss/ZAYK7Z%2BjpC9LlcAc%40lo= calhost >> . >> > --=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 e= mail 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/3296c082-c030-4075-94a7-fa34aed7e3c1n%40googlegroups.com. ------=_Part_5_144434501.1678669155558 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Perhaps one of these:

method 1, without ext= ernal conversion. Load the LaTeX package in markdown, insert the raw LaTeX = command:

``` markdown
---
he= ader-includes:
=C2=A0=C2=A0=C2=A0 ``` {=3Dlatex}
=C2=A0= =C2=A0=C2=A0 \usepackage{svg}
=C2=A0=C2=A0 ```
---

See illustration below:

\= includesvg[scale=3D1.0]{idea.svg}
```

= Downside: the image only shows in LaTeX/PDF output. You could use a filter = that allows you to hide/show bits depending on output formats, but then you= might as well use Bastien's filter.

metho= d 2, external conversion: as you've done, but you should use the standalone= document class (assuming it doesn't conflict with the svg package. It crop= s documents to the size of the image. See https://ctan.org/pkg/standalone <= br />

Best, J

On Monday, March 6, 2023 a= t 3:53:48=E2=80=AFPM UTC A A wrote:
I'd rather not write any filter= s for this, and convert to PDF or another format externally, then embed in = markdown. Is there perhaps a way to do that?

On Mon, 6 Mar 2023 at 16:46, Bastien DUMONT <bastien...-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org> wrote:
You= can include the command directly in the resulting LaTeX document. This fil= ter should do the job:

```
function Image(image)
=C2=A0 local file =3D image.src
=C2=A0 if FORMAT =3D=3D 'latex' and string.match(file, '%.svg$&= #39;) then
=C2=A0 =C2=A0 return pandoc.RawInline('latex', '\\includesvg[sc= ale=3D1.0]{' .. file .. '}')
=C2=A0 end
end
```


Le Monday 06 March 2023 =C3=A0 04:11:37PM, A A a =C3=A9crit :
> I=E2=80=99d like to include SVG graphics in my LaTeX document using pa= ndoc. I
> understand this is currently [1]not supported so I have resorted to th= e idea of
> performing the SVG to PDF conversion externally and then including in = my
> markdown using something like this:
>
> ![whee](foo.pdf)
>
> I would prefer not to do this conversion using raw inkscape because th= e svg
> package in LaTeX has the added advantage of rendering LaTeX math withi= n the
> figure if it encounters LaTeX math in the SVG. This won=E2=80=99t happ= en if I only use
> inkscape.
>
> Unfortunately, I haven=E2=80=99t found a way to ensure that the result= ing PDF is
> cropped to the extents of the image after doing a LaTeX compilation. F= or
> example:
>
> \documentclass{article}
>
> \usepackage{svg}
>
> \begin{document}
>=C2=A0 =C2=A0 =C2=A0\includesvg[scale=3D1.0]{idea.svg}
>
> \end{document}
>
> will compile as a full A4 sized page with page number. If I then inclu= de it in
> my markdown as ![idea](idea.pdf) I=E2=80=99d get the whole page as my = =E2=80=9Cfigure=E2=80=9D and not
> only the SVG.
>
> How can include SVGs with LaTeX math in Pandoc ?
>
> --
> You received this message because you are subscribed to the Google Gro= ups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send= an email
> to [2]pandoc-discus...@goog= legroups.com.
> To view this discussion on the web visit [3]https://groups.google.com/d/msgid/
> pandoc-discuss/
> CAMwawgPKcXu-CapB6d_vSWc7%3DvfA_sQSzFnnv4nGBurq6%2BMkEw%40mail.gmail.com.
>
> References:
>
> [1] https://github.com/jgm/pandoc/issues/265
> [2] mailto:pandoc-discus...= @googlegroups.com
> [3] https://groups.google.com/d/msgid/pandoc-discu= ss/CAMwawgPKcXu-CapB6d_vSWc7%3DvfA_sQSzFnnv4nGBurq6%2BMkEw%40mail.gmail.com= ?utm_medium=3Demail&utm_source=3Dfooter

--
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 pandoc-discus...@googleg= roups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/ZAYK7Z%2BjpC9LlcAc%40localhost.

--
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/3296c082-c030-4075-94a7-fa34aed7e3c1n%40googlegroups.= com.
------=_Part_5_144434501.1678669155558-- ------=_Part_4_2004024274.1678669155558--