* Using latex macros for html and pdf output
@ 2020-05-09 12:41 Germano Gabbianelli
[not found] ` <7ee100cd-c4d9-4e00-9648-7c11675be7dd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Germano Gabbianelli @ 2020-05-09 12:41 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1648 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 2718 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Using latex macros for html and pdf output
[not found] ` <7ee100cd-c4d9-4e00-9648-7c11675be7dd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-05-09 19:43 ` John MacFarlane
[not found] ` <m2y2q0gaie.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: John MacFarlane @ 2020-05-09 19:43 UTC (permalink / raw)
To: Germano Gabbianelli, pandoc-discuss
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Using latex macros for html and pdf output
[not found] ` <m2y2q0gaie.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-05-10 11:38 ` BPJ
0 siblings, 0 replies; 3+ messages in thread
From: BPJ @ 2020-05-10 11:38 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 3227 bytes --]
Or rather in a LaTeX block in the `header-includes` list in the YAML
metadata:
---
header-includes:
- |
```{=latex}
% LaTeX code here!
```
---
--
Better --help|less than helpless
Den lör 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
> 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
> .
>
> --
> 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%40johnmacfarlane.net
> .
>
--
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/CADAJKhDWg857-fwrboMYnQCHyJ6ON5tsJJtsfDYp7yh2i0Hcmw%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 4919 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-10 11:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09 12:41 Using latex macros for html and pdf output Germano Gabbianelli
[not found] ` <7ee100cd-c4d9-4e00-9648-7c11675be7dd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-09 19:43 ` John MacFarlane
[not found] ` <m2y2q0gaie.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-10 11:38 ` BPJ
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).