From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/25160 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Using latex macros for html and pdf output Date: Sun, 10 May 2020 13:38:05 +0200 Message-ID: References: <7ee100cd-c4d9-4e00-9648-7c11675be7dd@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000001ef0d05a549b26f" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="118781"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBJWQ372QKGQEEX4CGVY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun May 10 13:40:24 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f55.google.com ([209.85.128.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jXkJk-000Um9-NL for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 10 May 2020 13:40:24 +0200 Original-Received: by mail-wm1-f55.google.com with SMTP id 72sf6805083wmb.1 for ; Sun, 10 May 2020 04:40:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589110824; cv=pass; d=google.com; s=arc-20160816; b=OBHzuLATpei/+nzfa879q1G8qh70Wrp1sAj9NIGUs7oIfxlDPk43YQjNR7TGDaRYO8 QkxB5OBH1cbEO11sWAkKb7UyLoK1j/TTPDByIzP2LmkgOkt9EQOipmsQYlJhPUlJDru7 znFrC68jZMmSisjWmnIiwT0FOCNs5CKlRqLSNldFleN6pN3bVI7ggbLP3AznaVByNokd iiAKOcZ1y+Htu0TycLcEl5FivLUl5VrpYm8JFg6DlKNMsMx2JJtiGoo5nU5w2AYtr0SQ N4cfECJ55UjPtTn5NhfF543eU8rIZaJvSyXDniAREwbMPRbwh2lj5X8XqBt5pnoAOesn BkBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:sender:dkim-signature; bh=jT8wmj9PhWhy/unrkEMRdQFVJY350XM7GiqAYEwmxh8=; b=pPrR1RxO7AECf/mf8fZeMnjuGB+di2LkM97k1/UrSpJn2faBio8SjazRcDKl1Imy3X 9GA5rWLhzD8uqm0596L9/lWBypx/TGS6wj7ad/W00sITBvI7ekM4J6N2hTtEinHDJQnK qX1KGkwLepl2nwYO3CslXUpzgdC8o36ktnGk7MAk0hp1cF3rrfflAW54ozW+ZMY9n9kL iC411YV7oIpTebmHVyB7Obo3NhA7VB8JYCOWC5b1lYeOJCbRZcplNCC3PzrZtjP/JEv9 btkxB0tSXi6U4kbp+pG1DptmOyHXYCfgll+xxEE1obWl0Bdn0BN2tNP3QPHm+6iHtjdF CniA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.167.52 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:references:in-reply-to:reply-to:from:date :message-id:subject:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=jT8wmj9PhWhy/unrkEMRdQFVJY350XM7GiqAYEwmxh8=; b=HLUhTRULJOcTZsu5bztCz9tls508s3RY7VqAIjMglz6o2UH3Ct7+Q0wg91cYfsAKQq h1GufBf70KWyeBmaDtFC8VnFQTWFaEpjincm2TIeirecJgGI+/v1g1vJnhB2vKOApYpp xdgINHcWbrisQhrJEpRIk8+3RS1LZkoSzf30CVHlUywCQghZT6veZXLxzzo3L0RmbI+p r98Cee8+Ju3Wj4HgZI0QWouVfJZ7dwCJvV+s+cgBgIhqBn3BxeAug1gV1GufbPP8n+W7 sSUtq9tTS2dvXLnBovZ2vl1ueJr6F/Y6ZZep0GQYzrLPN8gU/DT9Wq9Sg6+3eSXx/0BD EZVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to :reply-to:from:date:message-id:subject:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=jT8wmj9PhWhy/unrkEMRdQFVJY350XM7GiqAYEwmxh8=; b=HBMw1k0HTjKV/rmh/0/yhHyuyrcZs1TDjp1+eS+dKKzgtZQJsUQ0gDoiamsB8SG/f/ UQeqeKTCIZNHQL6GOiOsaK61f8lEAuBrWvO7ACTqntAoB3l4dcLroSq8FRY7poChYb1V dYWV9LzdhpKAK9bFXR9aDY+3AuOwsIP74cjo38cmHuUI6Ytk34h8Q2/tI3Hkk8PnSqjS 4N9TbU8zgyThho8TzyISA41wniXu27W0823qcChWvSKpotjm7l67OcQOE07o5ZWwDYHK mGh8vyUbdbOIj+TWTozR5fLl2eQx7bjnZJAtPb/CDiC7Q3J+ZxnowUVb7GBmHkbw5xkG rnXw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AGi0PubzxzIN7zU6I+oY9jRJnDyxBehMD3Rtm1WIvulimvg45vTZn63H U6G5eis7RpgAC+FZ4iwIruc= X-Google-Smtp-Source: APiQypKoxdHkV+3lCg6nKmotWFl09den2HoHzqDQuG1PaHo2jGH808T06iSIawqHbVniEuLdszw8Gg== X-Received: by 2002:a7b:c205:: with SMTP id x5mr3734836wmi.135.1589110824270; Sun, 10 May 2020 04:40:24 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:fac9:: with SMTP id a9ls5214838wrs.2.gmail; Sun, 10 May 2020 04:40:22 -0700 (PDT) X-Received: by 2002:a5d:5607:: with SMTP id l7mr13423341wrv.370.1589110822053; Sun, 10 May 2020 04:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589110822; cv=none; d=google.com; s=arc-20160816; b=MDItrx+HzsEdB3Hw+vRJmE/jo0C0ShoMEgcfb+TcqSxhbRSwwtf1JN6kT6R9faosIt OD8dNI8OMY/Igw0hNX78hVUviy40u789qCZelUyDmdK7wjizCMgcPSgSFR+OdkB78DF0 XtvERzEoTNzptPqZPwudKGL0f5gqg+mP0vQwzyY137T5PLaSbbJXpR1ZDZ4Vn18jb/j3 KQFgTMQCUG99ELQ3mGXWzAfwapAT1VloyTFYrRNP2+RJNJ6gD7x5GixKxgcLosfPYxCn 26b1qr3PNxc3MdR935CkJmP+0GGU9k4e0e/CdbtbG5MbDFkwsivPeBrqdFTKPe+AmpCO 4b/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version; bh=h9ruGxVS3be35K3vpCVabvoWLTqO7ddiTIWju5KdKGg=; b=iWTPEJ8JI3cVpcWt1K/lh3ApcCs+svvTxNXCjW9IP/FQolMmWI88uLj9UZpVgjZ6gU f7JScA2ghv6YsQanikN9GMeP1UxvvhL8iZ31WpfauemPyhLWw31uNuUIJ3c23IUJZhDv l5HlVN1dTxzT2fh5RsqPP95jDu3Xa976mfr3wfhEQ4t3dNKnsYDzfhGeIANHOE8/jwwx 4D6aRd5wCKObJnjJUoG3QHvKd9CLCUg/2neyknAov4PCti4XTA8wH01tY1SOfWcO1QLn nDdUAbCpgSUyhbgBWDyZxaZhPFwCrHdJdH+4an7HwUVLbKsnX6GJyQ2yL7RqSkA1AAfH xOxQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.167.52 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Original-Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com. [209.85.167.52]) by gmr-mx.google.com with ESMTPS id m4si424566wrn.5.2020.05.10.04.40.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 May 2020 04:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.167.52 as permitted sender) client-ip=209.85.167.52; Original-Received: by mail-lf1-f52.google.com with SMTP id v5so935253lfp.13 for ; Sun, 10 May 2020 04:40:21 -0700 (PDT) X-Received: by 2002:a05:6512:10cd:: with SMTP id k13mr7567405lfg.153.1589110821218; Sun, 10 May 2020 04:40:21 -0700 (PDT) In-Reply-To: X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.167.52 as permitted sender) smtp.mailfrom=melroch-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:25160 Archived-At: --00000000000001ef0d05a549b26f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Or rather in a LaTeX block in the `header-includes` list in the YAML metadata: --- header-includes: - | ```{=3Dlatex} % LaTeX code here! ``` --- -- Better --help|less than helpless Den l=C3=B6r 9 maj 2020 21:44John MacFarlane skrev: > > Try putting it in > > header-includes > > in your YAML metadata. > > Germano Gabbianelli writes: > > > Hello, I have the following markdown source, containing some latex > macros > > and I would like to convert it both to html and pdf. > > > > > > --- > > title: Hello > > --- > > > > \DeclareMathOperator*{\E}{\mathbb E} > > > > This is some math: $\E x$ > > > > > > I can convert it to html, using `pandoc hello.md --mathml -s -o > out.html`, > > but conversion to pdf fails (complaining that \DeclareMathOperator can > only > > be used in the preamble): > > > > $ pandoc hello.md -f markdown-latex_macros -s -o out.pdf > > Error producing PDF. > > ! LaTeX Error: Can be used only in preamble. > > > > > > I can successfully convert the markdown to pdf, by moving the macros to > a > > separate `macros.tex` file and including it with `-H`, however I would > like > > to keep a single input markdown file, which should be converted to both > > html and pdf. > > Having the macros in a separate file would be ideal, so I could avoid > > duplicating them in each source file. > > > > > > I also tried to make a lua filter to dynamically include `macros.tex` > when > > converting to html, but it does not seem to work. > > > > > > mt, contents =3D pandoc.mediabag.fetch("etc/macros.tex", ".") > > macros =3D pandoc.read(contents).blocks > > > > function Pandoc(doc) > > return pandoc.Pandoc(macros .. doc.blocks, doc.meta) > > end > > > > > > Could anyone give me any hints? > > > > Thank you, > > Germano > > > > -- > > 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/7ee100cd-c4d9-4e00-9648-= 7c11675be7dd%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/m2y2q0gaie.fsf%40johnmac= farlane.net > . > --=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/CADAJKhDWg857-fwrboMYnQCHyJ6ON5tsJJtsfDYp7yh2i0Hcmw%40mail.g= mail.com. --00000000000001ef0d05a549b26f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Or rather in a LaTeX block in the `header-includes` list = in the YAML metadata:

---
header-includes:
=C2=A0 - |
=
=C2=A0 =C2=A0 ```{=3Dlatex}
=C2=A0= =C2=A0 % LaTeX code here!
=C2=A0 =C2=A0 ```
---


--
Better --help|less than helpless

Den l=C3=B6r 9 maj 2020 21:44John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> skrev:

Try putting it in

header-includes

in your YAML metadata.

Germano Gabbianelli <tyrion.mx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hello, I have the following markdown source, containing some latex mac= ros
> and I would like to convert it both to html and pdf.
>
>
> ---
> title: Hello
> ---
>
> \DeclareMathOperator*{\E}{\mathbb E}
>
> This is some math: $\E x$
>
>
> I can convert it to html, using `pandoc hello.md=C2=A0 --mathml -s -o = out.html`,
> but conversion to pdf fails (complaining that \DeclareMathOperator can= only
> be used in the preamble):
>
> $ pandoc hello.md=C2=A0 -f markdown-latex_macros -s -o out.pdf
> Error producing PDF.
> ! LaTeX Error: Can be used only in preamble.
>
>
> I can successfully convert the markdown to pdf, by moving the macros t= o a
> separate `macros.tex` file and including it with `-H`, however I would= like
> to keep a single input markdown file, which should be converted to bot= h
> html and pdf.
> Having the macros in a separate file would be ideal, so I could avoid =
> duplicating them in each source file.
>
>
> I also tried to make a lua filter to dynamically include `macros.tex` = when
> converting to html, but it does not seem to work.
>
>
> mt, contents =3D pandoc.mediabag.fetch("etc/macros.tex", &qu= ot;.")
> macros =3D pandoc.read(contents).blocks
>
> function Pandoc(doc)
>=C2=A0 =C2=A0 =C2=A0return pandoc.Pandoc(macros .. doc.blocks, doc.meta= )
> end
>
>
> Could anyone give me any hints?
>
> Thank you,
> Germano
>
> --
> 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 pandoc-discuss+unsubscribe@googlegr= oups.com.
> To view this discussion on the web visit https://groups= .google.com/d/msgid/pandoc-discuss/7ee100cd-c4d9-4e00-9648-7c11675be7dd%40g= ooglegroups.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 pandoc-discuss+unsubscribe@googlegroups.= com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pando= c-discuss/m2y2q0gaie.fsf%40johnmacfarlane.net.

--
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/CADAJKhDWg857-fwrboMYnQCHyJ6ON5tsJJtsfDYp= 7yh2i0Hcmw%40mail.gmail.com.
--00000000000001ef0d05a549b26f--