From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: Germano Gabbianelli
<tyrion.mx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
pandoc-discuss
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Using latex macros for html and pdf output
Date: Sat, 09 May 2020 12:43:05 -0700 [thread overview]
Message-ID: <m2y2q0gaie.fsf@johnmacfarlane.net> (raw)
In-Reply-To: <7ee100cd-c4d9-4e00-9648-7c11675be7dd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
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 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.
next prev parent reply other threads:[~2020-05-09 19:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 12:41 Germano Gabbianelli
[not found] ` <7ee100cd-c4d9-4e00-9648-7c11675be7dd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-09 19:43 ` John MacFarlane [this message]
[not found] ` <m2y2q0gaie.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-10 11:38 ` BPJ
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=m2y2q0gaie.fsf@johnmacfarlane.net \
--to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=tyrion.mx-Re5JQEeQqe8AvxtiuMwx3w@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).