From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/25158 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Germano Gabbianelli Newsgroups: gmane.text.pandoc Subject: Using latex macros for html and pdf output Date: Sat, 9 May 2020 05:41:55 -0700 (PDT) Message-ID: <7ee100cd-c4d9-4e00-9648-7c11675be7dd@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_939_1435179160.1589028115032" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="49091"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBD2O5JPERYERBFGK3L2QKGQEOKRENEA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat May 09 14:41:59 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f58.google.com ([209.85.161.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jXOnn-000CbY-Gd for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 09 May 2020 14:41:59 +0200 Original-Received: by mail-oo1-f58.google.com with SMTP id s23sf3343423ook.7 for ; Sat, 09 May 2020 05:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=oIEKFL9wqbKWFnvq8q2xo8+knzid4N5sY5BMKlC4yS0=; b=CzC07P7Lv/9lEXzKikATgcmCvoNCKD10P5NCni/eqL6DjiVP9LwfBvw+j2XLiiQj2r Lu+teIqoVNXcOUm7IEsyRwLBposnZzHzH3DvFCu3RDMU8a3pe9B/25sMD9PPqBkIisps yJ1tVy8o+IBve4XLZVElQDKfvWbq9sIr019SnGzbRDPAoLc5mZsDw6kUYIkaim30V58n ryLW0RwXayv/eICRHv7Y03Bqbbgg0QUHctYtuAFpt/D9aEPy2M9tbSKqU//52tK/DZs+ 58lnIuHFjBqypRnKEvZiAHI7NmyGTqvQ7O+yKA+Dc/RQ2ssZbjYKCgaYWjIJGDyn6NrG GoOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:subject:mime-version:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=oIEKFL9wqbKWFnvq8q2xo8+knzid4N5sY5BMKlC4yS0=; b=bXCFPsKiRmTdYoaZtIaKSuRA9uDgZUbzm+wjebuPbEQ68d53y501/bslItJIr+34zf OvmC4MsDsQvTs00uArWW3MaXcD4Boo0jVyY0QepDdzJ+21qByxAPB06ptapqwBhlkGSZ b/ZKqrLhrJZOdcCENwoQroxF5VnhI4tekq3bSkMHTESPr6YrED2k4L+nNrEeXvcfkqvr Un6gAIuCIc13eIGYHbhgqmnrTgrd05oSufVsbxOrSOHbO9WQlxq4E9jtpyQ6CYbpxynv HEslKGrVbkOIjixfsPEz3LH8qNr+Lj5oQ8ALoZjPVBEtDhh1IGHwI1v7R2gQ9Ch4R/0q rP8w== 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: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=oIEKFL9wqbKWFnvq8q2xo8+knzid4N5sY5BMKlC4yS0=; b=GnHSztephwYI+0g7WoolWHAlHpmvFY6QoOKCeuLwRwjisCXLGVXvKAx0W1QSx6YqZq gPNAX5udpD+xAop+jsYkfVfHCKLfk8Ek2bveU7drjQqjztnX5XaMTJy1AfIjTA3tT7bB P3JC8hmxPSo6m/zwXDD+qQn4gzsKrHA94Kj40hN4pwFjT7x98WbIsZBFCPzk7sZ7or/e gqSQ79rRJWSQLiq0DgTtCsJCQa59Eu3A9oVQMP7SjrkeE8VNewrGqq8KigXW3thVC3uN P/beeb7053r6YJ47ERJa+27vZ1y13awsk9Q/FJAxArD9CtNLoreNBOd+PEgGM0S/DP9S st8Q== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AGi0PuaQ+pcydOHOhNavv43m7tzIAqk0w7cQBBh4y831eRZktnjmHXXs GU5MXCwR9YEL//1zeeQ6U1c= X-Google-Smtp-Source: APiQypJgean69YfRnI17ThBBxuEhlBgNSwK2k8/bFwETX7Bjp5s3hPE5d2aMdUnbFQKtVkNZjHQUdA== X-Received: by 2002:a9d:67c2:: with SMTP id c2mr5360306otn.227.1589028118419; Sat, 09 May 2020 05:41:58 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:1de1:: with SMTP id b1ls1062887otj.9.gmail; Sat, 09 May 2020 05:41:55 -0700 (PDT) X-Received: by 2002:a9d:a55:: with SMTP id 79mr6041485otg.295.1589028115779; Sat, 09 May 2020 05:41:55 -0700 (PDT) X-Original-Sender: Tyrion.MX-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:25158 Archived-At: ------=_Part_939_1435179160.1589028115032 Content-Type: multipart/alternative; boundary="----=_Part_940_717232585.1589028115032" ------=_Part_940_717232585.1589028115032 Content-Type: text/plain; charset="UTF-8" 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 = pandoc.mediabag.fetch("etc/macros.tex", ".") macros = 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. ------=_Part_940_717232585.1589028115032 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello, I have the following markdown source, containi= ng some latex macros and I would like to convert it both to html and pdf.


This is some math: $\E x$

I can convert it to html, using `pandoc hello.m= d=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 m= arkdown-latex_macros -s -o out.pdf
Error producing PDF.
! LaTeX Error= : Can be used only in preamble.


<= div>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 l= ike 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 idea= l, 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.me= diabag.fetch("etc/macros.tex", ".")
macros =3D pando= c.read(contents).blocks

function Pandoc(doc)
=C2=A0=C2=A0=C2=A0 r= eturn 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 &= 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/7ee100cd-c4d9-4e00-9648-7c11675be7dd%40googlegroups.co= m.
------=_Part_940_717232585.1589028115032-- ------=_Part_939_1435179160.1589028115032--