public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Hiding TeX headers from HTML output
@ 2020-08-25 18:20 Pranesh Prakash
       [not found] ` <a669b6a7-167e-4056-b0fa-546e4fe53d7fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Pranesh Prakash @ 2020-08-25 18:20 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1653 bytes --]


Hi all,
I use the TeX files paragraphs.tex and footnotes.tex to style the 
paragraphs and footnotes in PDFs.  (The input file is in pandoc-flavour 
markdown.)  I use them via a defaults files using "include-in-header: \n - 
paragraphs.tex \n - footnotes.tex".  When I convert the file to HTML, the 
TeX component shows up.  (It is in the <head> </head> part, before <body>, 
but still shows up on the screen when I open the file.)

I've tried using the modified TeX files where I enclose them in code fences 
with {=pdf} and {=latex} as well. Each time I do this, I get the error:

> Error producing PDF.
> ! LaTeX Error: Missing \begin{document}.
> 
>  See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.43 `
> 

I get this same error if I try to include the headers using 
"header-include:" instead of "include-in-header:". 

I've tried marking the input format as "markdown+raw_attribute" and as 
"markdown+raw_tex", but that doesn't change anything.

What am I doing wrong?  How do I prevent the PDF/LaTeX-specific headers 
from being used for outputs like HTML?

Regards,
Pranesh

-- 
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/a669b6a7-167e-4056-b0fa-546e4fe53d7fn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2725 bytes --]

[-- Attachment #2: paragraphs-pdf.tex --]
[-- Type: text/x-tex, Size: 96 bytes --]

```{=pdf}
\usepackage{parskip}
\setlength{\parskip}{5pt plus1pt}
\setlength\parindent{1.5em}
```

[-- Attachment #3: footnotes-latex.tex --]
[-- Type: text/x-tex, Size: 151 bytes --]

```{=latex}
\usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
\usepackage[hang,bottom,multiple]{footmisc}
\setlength{\footnotesep}{3mm}
```

[-- Attachment #4: paragraphs.tex --]
[-- Type: text/x-tex, Size: 83 bytes --]

\usepackage{parskip}
\setlength{\parskip}{5pt plus1pt}
\setlength\parindent{1.5em}

[-- Attachment #5: footnotes.tex --]
[-- Type: text/x-tex, Size: 135 bytes --]

\usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
\usepackage[hang,bottom,multiple]{footmisc}
\setlength{\footnotesep}{3mm}

[-- Attachment #6: footnotes-pdf.tex --]
[-- Type: text/x-tex, Size: 148 bytes --]

```{=pdf}
\usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
\usepackage[hang,bottom,multiple]{footmisc}
\setlength{\footnotesep}{3mm}
```

[-- Attachment #7: paragraphs-latex.tex --]
[-- Type: text/x-tex, Size: 98 bytes --]

```{=latex}
\usepackage{parskip}
\setlength{\parskip}{5pt plus1pt}
\setlength\parindent{1.5em}
```

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Hiding TeX headers from HTML output
       [not found] ` <a669b6a7-167e-4056-b0fa-546e4fe53d7fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-08-25 19:53   ` Pranesh Prakash
  2020-08-25 21:44   ` John MacFarlane
  1 sibling, 0 replies; 6+ messages in thread
From: Pranesh Prakash @ 2020-08-25 19:53 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1284 bytes --]

On Tuesday, 25 August, 2020 at 11:50:33 pm UTC+5:30 Pranesh Prakash wrote:
> Error producing PDF.
> ! LaTeX Error: Missing \begin{document}.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type H <return> for immediate help.
> ... 
> 
> l.43 `
> 

Investigating using `--verbose`, I find that the intermediate file has the 
"```{=latex}" / "```{=pdf}" intact:

\setcounter{secnumdepth}{5}
```{=latex}
\usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
\usepackage[hang,bottom,multiple]{footmisc}
\setlength{\footnotesep}{3mm}
```
```{=latex}
\usepackage{parskip}
\setlength{\parskip}{5pt plus1pt}
\setlength\parindent{1.5em}
```
\ifxetex
  % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. 
Hebrew, Arabic)


This back-tick is what is causing the error.

Clearly I've done something wrong in the way I include the headers.

-- 
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/5410022c-4154-4c69-999a-8862f97a8f8an%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1889 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Hiding TeX headers from HTML output
       [not found] ` <a669b6a7-167e-4056-b0fa-546e4fe53d7fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-08-25 19:53   ` Pranesh Prakash
@ 2020-08-25 21:44   ` John MacFarlane
       [not found]     ` <m28se2v1sb.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2020-08-25 21:44 UTC (permalink / raw)
  To: Pranesh Prakash, pandoc-discuss


header-includes is the field name to use.

Pranesh Prakash <the.solipsist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi all,
> I use the TeX files paragraphs.tex and footnotes.tex to style the 
> paragraphs and footnotes in PDFs.  (The input file is in pandoc-flavour 
> markdown.)  I use them via a defaults files using "include-in-header: \n - 
> paragraphs.tex \n - footnotes.tex".  When I convert the file to HTML, the 
> TeX component shows up.  (It is in the <head> </head> part, before <body>, 
> but still shows up on the screen when I open the file.)
>
> I've tried using the modified TeX files where I enclose them in code fences 
> with {=pdf} and {=latex} as well. Each time I do this, I get the error:
>
>> Error producing PDF.
>> ! LaTeX Error: Missing \begin{document}.
>> 
>>  See the LaTeX manual or LaTeX Companion for explanation.
>> Type  H <return>  for immediate help.
>>  ...                                              
>>                                                   
>> l.43 `
>> 
>
> I get this same error if I try to include the headers using 
> "header-include:" instead of "include-in-header:". 
>
> I've tried marking the input format as "markdown+raw_attribute" and as 
> "markdown+raw_tex", but that doesn't change anything.
>
> What am I doing wrong?  How do I prevent the PDF/LaTeX-specific headers 
> from being used for outputs like HTML?
>
> Regards,
> Pranesh
>
> -- 
> 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/a669b6a7-167e-4056-b0fa-546e4fe53d7fn%40googlegroups.com.
> ```{=pdf}
> \usepackage{parskip}
> \setlength{\parskip}{5pt plus1pt}
> \setlength\parindent{1.5em}
> ```
> ```{=latex}
> \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
> \usepackage[hang,bottom,multiple]{footmisc}
> \setlength{\footnotesep}{3mm}
> ```
> \usepackage{parskip}
> \setlength{\parskip}{5pt plus1pt}
> \setlength\parindent{1.5em}
> \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
> \usepackage[hang,bottom,multiple]{footmisc}
> \setlength{\footnotesep}{3mm}
> ```{=pdf}
> \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
> \usepackage[hang,bottom,multiple]{footmisc}
> \setlength{\footnotesep}{3mm}
> ```
> ```{=latex}
> \usepackage{parskip}
> \setlength{\parskip}{5pt plus1pt}
> \setlength\parindent{1.5em}
> ```


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Hiding TeX headers from HTML output
       [not found]     ` <m28se2v1sb.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-08-25 22:06       ` Pranesh Prakash
       [not found]         ` <95f7f71e-6af3-4d73-b47e-dd7bd28585e9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Pranesh Prakash @ 2020-08-25 22:06 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1672 bytes --]

On Wednesday, 26 August, 2020 at 3:14:37 am UTC+5:30 John MacFarlane wrote:
> header-includes is the field name to use. 

If I use header-includes in my defaults.yaml file thusly, without 
back-ticks:
---
metadata:
   header-includes: |
   \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
   \usepackage[hang,bottom]{footmisc}
   \setlength{\footnotesep}{3mm}
...

I get the following error:

> Error producing PDF.
> ! LaTeX Error: Missing \begin{document}.
> 
>  See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.43 \textbackslash

If I use header-includes in my defaults.yaml file thusly, with back-ticks:
---
metadata:
   header-includes:
  - |
   ```{=latex}
   \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
   \usepackage[hang,bottom]{footmisc}
   \setlength{\footnotesep}{3mm}
   ```
...

I get the following error:

> Error producing PDF.
> ! LaTeX Error: Missing \begin{document}.
> 
>  See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>  
> l.43 `

Regards,
Pranesh

-- 
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/95f7f71e-6af3-4d73-b47e-dd7bd28585e9n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3214 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Hiding TeX headers from HTML output
       [not found]         ` <95f7f71e-6af3-4d73-b47e-dd7bd28585e9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-08-26  6:18           ` John MacFarlane
       [not found]             ` <m2r1ruszed.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2020-08-26  6:18 UTC (permalink / raw)
  To: Pranesh Prakash, pandoc-discuss


OK, I thought you were talking about metadata in the document,
not defaults.yaml.  defaults.yaml isn't quite the same -- it
is a way of specifying default values for things you can specify
on the command line, and they work the same for the most part.
Metadata in defaults.yaml files is NOT parsed as Markdown,
but rather as plain text, just like --metadata on the command line.

This is pointed out in the documentation, which notes:

# metadata values specified here are parsed as literal
# string text, not markdown

If you want to include some metadata conditionally,
depending on the output format, but NOT by adding
header-includes to the YAML metadata in a markdown
file, then your best bet is to use a lua filter, which
has access to the output format in the FORMAT variable
and can insert the appropriate thing into header-includes
in the document's metadata.


Pranesh Prakash <the.solipsist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> On Wednesday, 26 August, 2020 at 3:14:37 am UTC+5:30 John MacFarlane wrote:
>> header-includes is the field name to use. 
>
> If I use header-includes in my defaults.yaml file thusly, without 
> back-ticks:
> ---
> metadata:
>    header-includes: |
>    \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
>    \usepackage[hang,bottom]{footmisc}
>    \setlength{\footnotesep}{3mm}
> ...
>
> I get the following error:
>
>> Error producing PDF.
>> ! LaTeX Error: Missing \begin{document}.
>> 
>>  See the LaTeX manual or LaTeX Companion for explanation.
>> Type  H <return>  for immediate help.
>>  ...                                              
>>                                                   
>> l.43 \textbackslash
>
> If I use header-includes in my defaults.yaml file thusly, with back-ticks:
> ---
> metadata:
>    header-includes:
>   - |
>    ```{=latex}
>    \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
>    \usepackage[hang,bottom]{footmisc}
>    \setlength{\footnotesep}{3mm}
>    ```
> ...
>
> I get the following error:
>
>> Error producing PDF.
>> ! LaTeX Error: Missing \begin{document}.
>> 
>>  See the LaTeX manual or LaTeX Companion for explanation.
>> Type  H <return>  for immediate help.
>>  ...                                              
>>  
>> l.43 `
>
> Regards,
> Pranesh
>
> -- 
> 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/95f7f71e-6af3-4d73-b47e-dd7bd28585e9n%40googlegroups.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Hiding TeX headers from HTML output
       [not found]             ` <m2r1ruszed.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-08-26 10:48               ` Pranesh Prakash
  0 siblings, 0 replies; 6+ messages in thread
From: Pranesh Prakash @ 2020-08-26 10:48 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 4538 bytes --]

Goodness gracious me!  It's all worked out.  I started using `-H` for 
including the tex files some years ago not to avoid using 
`header-includes`, but because I couldn't get in-file `headers-include` to 
work properly.  It probably wasn't working correctly back then because I 
hadn't used ```{=latex}.  But now, finally, this worked, when placed in the 
in-file YAML metadata block:
```
header-includes: |
  ```{=latex}
  \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
  \setlength{\parskip}{9pt plus1pt}
  \setlength{\parindent}{1.5em}
  \usepackage[hang,bottom,multiple]{footmisc}
  \setlength{\footnotesep}{3mm}
  ```
```

Thanks so much John!

I think eventually I will try to learn a bit of Lua to write a filter for 
this, since it's a bit ungainly to keep copy-pasting this snippet into each 
document I write.

One work-around (I think, if that's the right word), which seems to work 
for me:

Create a latex-headers.md with the above `header-includes` YAML metadata, 
and include it as an input file (from being "markdown") in addition to your 
main file.  Then it seems to (a) get parsed as markdown, (b) recognized as 
`headers-includes` metadata, (c) results in the LaTeX being used to create 
PDFs, but not showing up in the HTML.

And thank you so much for the defaults system. It's a game-changer for the 
coding-challenged amongst us.
On Wednesday, 26 August, 2020 at 11:49:07 am UTC+5:30 John MacFarlane wrote:

>
> OK, I thought you were talking about metadata in the document,
> not defaults.yaml. defaults.yaml isn't quite the same -- it
> is a way of specifying default values for things you can specify
> on the command line, and they work the same for the most part.
> Metadata in defaults.yaml files is NOT parsed as Markdown,
> but rather as plain text, just like --metadata on the command line.
>
> This is pointed out in the documentation, which notes:
>
> # metadata values specified here are parsed as literal
> # string text, not markdown
>
> If you want to include some metadata conditionally,
> depending on the output format, but NOT by adding
> header-includes to the YAML metadata in a markdown
> file, then your best bet is to use a lua filter, which
> has access to the output format in the FORMAT variable
> and can insert the appropriate thing into header-includes
> in the document's metadata.
>
>
> Pranesh Prakash <the.so...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > On Wednesday, 26 August, 2020 at 3:14:37 am UTC+5:30 John MacFarlane 
> wrote:
> >> header-includes is the field name to use. 
> >
> > If I use header-includes in my defaults.yaml file thusly, without 
> > back-ticks:
> > ---
> > metadata:
> > header-includes: |
> > \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
> > \usepackage[hang,bottom]{footmisc}
> > \setlength{\footnotesep}{3mm}
> > ...
> >
> > I get the following error:
> >
> >> Error producing PDF.
> >> ! LaTeX Error: Missing \begin{document}.
> >> 
> >> See the LaTeX manual or LaTeX Companion for explanation.
> >> Type H <return> for immediate help.
> >> ... 
> >> 
> >> l.43 \textbackslash
> >
> > If I use header-includes in my defaults.yaml file thusly, with 
> back-ticks:
> > ---
> > metadata:
> > header-includes:
> > - |
> > ```{=latex}
> > \usepackage{microtype,parskip,bookmark,setspace,xurl,secdot}
> > \usepackage[hang,bottom]{footmisc}
> > \setlength{\footnotesep}{3mm}
> > ```
> > ...
> >
> > I get the following error:
> >
> >> Error producing PDF.
> >> ! LaTeX Error: Missing \begin{document}.
> >> 
> >> See the LaTeX manual or LaTeX Companion for explanation.
> >> Type H <return> for immediate help.
> >> ... 
> >> 
> >> l.43 `
> >
> > Regards,
> > Pranesh
> >
> > -- 
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/95f7f71e-6af3-4d73-b47e-dd7bd28585e9n%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/8eccb293-2c5b-492f-9ac0-8cc505cfa4efn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 6360 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-26 10:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 18:20 Hiding TeX headers from HTML output Pranesh Prakash
     [not found] ` <a669b6a7-167e-4056-b0fa-546e4fe53d7fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-25 19:53   ` Pranesh Prakash
2020-08-25 21:44   ` John MacFarlane
     [not found]     ` <m28se2v1sb.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-08-25 22:06       ` Pranesh Prakash
     [not found]         ` <95f7f71e-6af3-4d73-b47e-dd7bd28585e9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-26  6:18           ` John MacFarlane
     [not found]             ` <m2r1ruszed.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-08-26 10:48               ` Pranesh Prakash

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).