public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Workflow for quickly customizing PDF layout
@ 2018-09-05 18:09 mb21
       [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: mb21 @ 2018-09-05 18:09 UTC (permalink / raw)
  To: pandoc-discuss


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

I’m interested in learning whether other pandoc users use it to write 
letters or other short documents (i.e. shorter than a thesis) that need to 
be exported to PDF or printed, and what your workflow is like. Let me tell 
you about mine:

I start with writing down the text in a markdown file. This is great, 
because it forces me to focus on the content and prevents me from 
procrastinating by fiddling with the layout of the document.

When I’m done with the content, I choose a template and use pandoc to 
export to PDF. I get a feel of how many pages the text takes and whether I 
should add more paragraphs, subtitles etc. Then comes the time to refine 
the layout for this specific document: add page breaks etc. to avoid widows 
and orphans, or  adjust the font size and margins for very short letters 
that would look lost on a large sheet of paper.

Again, I’m talking relatively short documents here, that contain no 
citations etc. I guess, that’s what most people would use Word for, but I 
just cannot bring myself to use it – bad memories.

I used to export to PDF mostly with LaTeX, but lately I’ve come to use CSS 
(and wkhtmltopdf) more often. For one, because I know CSS by heart, and it 
always takes me too much time to look up how specific LaTeX packages work. 
For another, because I can use the browser’s developer tools to adjust CSS 
and get immediate visual feedback, whereas with LaTeX, compilation usually 
takes a few seconds.

I’ve been experimenting with a few different ways to add those few 
document-specific lines of CSS that override some things in the template.

1. Copy and customize a pandoc template (but that leaves me with lots of 
template files, in lots of directories, that are almost identical).
2. Add a `<style>` tag with the CSS via the `header-includes` variable.
3. Add the `<style>` tag directly to the document body.

All of the above are somewhat unsatisfying to me.

Inspired by 
[CSS-in-JS](https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660), 
I was thinking of putting something like the following in a markdown file’s 
YAML metadata:

    ---
    css:
      - p:
          font-size: 30px
      - li:
          margin: 20px
    ---

For this to work with pandoc out of the box, we would have to put something 
like the following in the HTML template, and extend the templating language 
with the `$key` and `$val` constructs:

    <style type="text/css">
    $for(css)$
    $key(css)$ {
      $for(css)$
      $key(css)$: $val(css)$;
      $endfor$
    }
    $endfor$
    </style>

So... this turned out to be longer than expected.

Long story short: what do you think? what’s your workflow to quickly and 
painlessly layout shorter documents for PDF export?

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/784b07a6-19bd-4ddc-9cfb-67440f6becd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Workflow for quickly customizing PDF layout
       [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-09-06 17:46   ` John MacFarlane
       [not found]     ` <m2zhwuy0wo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  2018-09-06 23:41   ` John Muccigrosso
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: John MacFarlane @ 2018-09-06 17:46 UTC (permalink / raw)
  To: mb21, pandoc-discuss


I personally use pdf via latex, and the only things I ever
mess with are fonts, font sizes, line stretch, and margins.

Don't forget that if you want a really fast PDF,
pandoc now offers `-t ms -o your.pdf`, which is
extremely fast and has lightweight dependencies.
You can customize pointsize, lineheight, fontfamily,
paragraph indent, and papersize in metadata; other
changes (e.g. to margins) currently require raw
groff commands or a custom template.

mb21 <mauro.bieg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I’m interested in learning whether other pandoc users use it to write 
> letters or other short documents (i.e. shorter than a thesis) that need to 
> be exported to PDF or printed, and what your workflow is like. Let me tell 
> you about mine:
>
> I start with writing down the text in a markdown file. This is great, 
> because it forces me to focus on the content and prevents me from 
> procrastinating by fiddling with the layout of the document.
>
> When I’m done with the content, I choose a template and use pandoc to 
> export to PDF. I get a feel of how many pages the text takes and whether I 
> should add more paragraphs, subtitles etc. Then comes the time to refine 
> the layout for this specific document: add page breaks etc. to avoid widows 
> and orphans, or  adjust the font size and margins for very short letters 
> that would look lost on a large sheet of paper.
>
> Again, I’m talking relatively short documents here, that contain no 
> citations etc. I guess, that’s what most people would use Word for, but I 
> just cannot bring myself to use it – bad memories.
>
> I used to export to PDF mostly with LaTeX, but lately I’ve come to use CSS 
> (and wkhtmltopdf) more often. For one, because I know CSS by heart, and it 
> always takes me too much time to look up how specific LaTeX packages work. 
> For another, because I can use the browser’s developer tools to adjust CSS 
> and get immediate visual feedback, whereas with LaTeX, compilation usually 
> takes a few seconds.
>
> I’ve been experimenting with a few different ways to add those few 
> document-specific lines of CSS that override some things in the template.
>
> 1. Copy and customize a pandoc template (but that leaves me with lots of 
> template files, in lots of directories, that are almost identical).
> 2. Add a `<style>` tag with the CSS via the `header-includes` variable.
> 3. Add the `<style>` tag directly to the document body.
>
> All of the above are somewhat unsatisfying to me.
>
> Inspired by 
> [CSS-in-JS](https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660), 
> I was thinking of putting something like the following in a markdown file’s 
> YAML metadata:
>
>     ---
>     css:
>       - p:
>           font-size: 30px
>       - li:
>           margin: 20px
>     ---
>
> For this to work with pandoc out of the box, we would have to put something 
> like the following in the HTML template, and extend the templating language 
> with the `$key` and `$val` constructs:
>
>     <style type="text/css">
>     $for(css)$
>     $key(css)$ {
>       $for(css)$
>       $key(css)$: $val(css)$;
>       $endfor$
>     }
>     $endfor$
>     </style>
>
> So... this turned out to be longer than expected.
>
> Long story short: what do you think? what’s your workflow to quickly and 
> painlessly layout shorter documents for PDF export?
>
> -- 
> 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/784b07a6-19bd-4ddc-9cfb-67440f6becd8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2zhwuy0wo.fsf%40johnmacfarlane.net.
For more options, visit https://groups.google.com/d/optout.


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

* Re: Workflow for quickly customizing PDF layout
       [not found]     ` <m2zhwuy0wo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2018-09-06 18:10       ` John Gabriele
       [not found]         ` <1536257449.4113114.1499279232.7E93AF7A-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
  2018-09-06 20:05       ` Joseph Reagle
  2018-09-08 10:29       ` mb21
  2 siblings, 1 reply; 13+ messages in thread
From: John Gabriele @ 2018-09-06 18:10 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

What output format does the `ms` indicate in `pandoc -t ms -o your.pdf`?


On Thu, Sep 6, 2018, at 1:46 PM, John MacFarlane wrote:
> 
> I personally use pdf via latex, and the only things I ever
> mess with are fonts, font sizes, line stretch, and margins.
> 
> Don't forget that if you want a really fast PDF,
> pandoc now offers `-t ms -o your.pdf`, which is
> extremely fast and has lightweight dependencies.
> You can customize pointsize, lineheight, fontfamily,
> paragraph indent, and papersize in metadata; other
> changes (e.g. to margins) currently require raw
> groff commands or a custom template.


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

* Re: Workflow for quickly customizing PDF layout
       [not found]         ` <1536257449.4113114.1499279232.7E93AF7A-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
@ 2018-09-06 18:20           ` T. Kurt Bond
  0 siblings, 0 replies; 13+ messages in thread
From: T. Kurt Bond @ 2018-09-06 18:20 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 2146 bytes --]

It indicates output to gnu troff <https://www.gnu.org/software/groff/>
using the ms macros.  These are available on most Unix derivatives.

On Thu, Sep 6, 2018 at 2:10 PM, John Gabriele <jgabriele-97jfqw80gc6171pxa8y+qA@public.gmane.org> wrote:

> What output format does the `ms` indicate in `pandoc -t ms -o your.pdf`?
>
>
> On Thu, Sep 6, 2018, at 1:46 PM, John MacFarlane wrote:
> >
> > I personally use pdf via latex, and the only things I ever
> > mess with are fonts, font sizes, line stretch, and margins.
> >
> > Don't forget that if you want a really fast PDF,
> > pandoc now offers `-t ms -o your.pdf`, which is
> > extremely fast and has lightweight dependencies.
> > You can customize pointsize, lineheight, fontfamily,
> > paragraph indent, and papersize in metadata; other
> > changes (e.g. to margins) currently require raw
> > groff commands or a custom template.
>
> --
> 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pandoc-discuss/1536257449.4113114.1499279232.7E93AF7A%40webmail.
> messagingengine.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV9qZ5ajzKxc34j2ek3ZbdzaH9yqnfLL5bUSKicvQ5xxPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 3639 bytes --]

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

* Re: Workflow for quickly customizing PDF layout
       [not found]     ` <m2zhwuy0wo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  2018-09-06 18:10       ` John Gabriele
@ 2018-09-06 20:05       ` Joseph Reagle
       [not found]         ` <707a6888-0343-05a2-3514-ccb6492caace-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
  2018-09-08 10:29       ` mb21
  2 siblings, 1 reply; 13+ messages in thread
From: Joseph Reagle @ 2018-09-06 20:05 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, mb21


BTW: In addition to wkhtmltopdf there's now <https://weasyprint.org> .

On 9/6/18 1:46 PM, John MacFarlane wrote:
> Don't forget that if you want a really fast PDF,
> pandoc now offers `-t ms -o your.pdf`, which is

I just tried that, doesn't appear to support images?

> You can customize pointsize, lineheight, fontfamily,
> paragraph indent, and papersize in metadata;

In the markdown YAML or elsewhere?


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

* Re: Workflow for quickly customizing PDF layout
       [not found]         ` <707a6888-0343-05a2-3514-ccb6492caace-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
@ 2018-09-06 20:28           ` T. Kurt Bond
       [not found]             ` <CAN1EhV__kD7JDKdN5q18PWB4TH5Vx3s_ot1JttF2FQFOD1mpfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2018-09-06 20:34           ` mb21
  1 sibling, 1 reply; 13+ messages in thread
From: T. Kurt Bond @ 2018-09-06 20:28 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

>> Don't forget that if you want a really fast PDF,
>> pandoc now offers `-t ms -o your.pdf`, which is
> I just tried that, doesn't appear to support images?

It doesn't look as if pandoc ms output supports images.  gnu troff supports
images, but they have to be in postscript, if you are using -Tps output, or
in PDF if you are using -Tpdf output.  It sure would be useful if those
options could be supported for images.

>> You can customize pointsize, lineheight, fontfamily,
>> paragraph indent, and papersize in metadata;
> In the markdown YAML or elsewhere?

In the markdown YAML metadata block, or on the command line using
--variable.

-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV__kD7JDKdN5q18PWB4TH5Vx3s_ot1JttF2FQFOD1mpfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 3067 bytes --]

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

* Re: Workflow for quickly customizing PDF layout
       [not found]         ` <707a6888-0343-05a2-3514-ccb6492caace-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
  2018-09-06 20:28           ` T. Kurt Bond
@ 2018-09-06 20:34           ` mb21
  1 sibling, 0 replies; 13+ messages in thread
From: mb21 @ 2018-09-06 20:34 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks! I must admit that I haven't tried groff yet. What's the recommended 
way to get it working on macOS? It appears groff comes still bundled with 
the system, but not pdfroff anymore. So `brew install groff`, or..? (There 
is also pdfroff.sh 
<https://opensource.apple.com/source/groff/groff-39/groff/contrib/pdfmark/pdfroff.sh>, 
but it complains it can't find awk...)

But probably, in the end I will tend to something CSS-based, where I can 
just quickly add a logo image in the header or some formatting in the 
footer (without learning groff or various latex packages). Not saying CSS 
is the best technology, just the one I'm most familiar with. But maybe most 
pandoc users are more familiar with LaTeX than CSS...?


> You can customize pointsize, lineheight, fontfamily, 
> > paragraph indent, and papersize in metadata; 
>
> In the markdown YAML or elsewhere?
>

Yes, via YAML or the `-M` option. See 
http://pandoc.org/MANUAL.html#variables-for-ms 

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/48bcab84-51b8-49db-ac10-ba185b2f43d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Workflow for quickly customizing PDF layout
       [not found]             ` <CAN1EhV__kD7JDKdN5q18PWB4TH5Vx3s_ot1JttF2FQFOD1mpfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-09-06 21:01               ` T. Kurt Bond
  0 siblings, 0 replies; 13+ messages in thread
From: T. Kurt Bond @ 2018-09-06 21:01 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]

> It doesn't look as if pandoc ms output supports images.  gnu troff
supports images, but they have to be in postscript, if you are using -Tps
output, or in PDF if you are using -Tpdf output.  It sure would be useful
if those options could be supported for images.


I spoke too soon! I looked at the source for src/Text/Pandoc/Writers/Ms.hs
and It turns out that there is support for images via the implicit_figures
extension, where a image with a nonempty alt text, occurring by itself in a
paragraph, is rendered as a figure with a caption.  The image has to be .ps
or .eps.

What it doesn't support is inline images.  I can see why that would be
impossible to implement in groff.
-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV86CsT-k52mDh%3DoXchK8FRdeBSTAa%2Bw10azqbre%3D0-BWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 2501 bytes --]

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

* Re: Workflow for quickly customizing PDF layout
       [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2018-09-06 17:46   ` John MacFarlane
@ 2018-09-06 23:41   ` John Muccigrosso
  2018-09-08 17:36   ` BP Jonsson
  2018-09-08 18:12   ` BP Jonsson
  3 siblings, 0 replies; 13+ messages in thread
From: John Muccigrosso @ 2018-09-06 23:41 UTC (permalink / raw)
  To: pandoc-discuss


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

TBH, for simple things, I use a markdown editor (MacDown) and print to PDF 
from there.

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/73f7b9f9-5b5a-41f7-aa4e-a22b836332c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Workflow for quickly customizing PDF layout
       [not found]     ` <m2zhwuy0wo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  2018-09-06 18:10       ` John Gabriele
  2018-09-06 20:05       ` Joseph Reagle
@ 2018-09-08 10:29       ` mb21
  2 siblings, 0 replies; 13+ messages in thread
From: mb21 @ 2018-09-08 10:29 UTC (permalink / raw)
  To: pandoc-discuss


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



> I personally use pdf via latex, and the only things I ever 
> mess with are fonts, font sizes, line stretch, and margins. 
>

Yes, for me it's usually the same. Maybe additionally page breaks and image 
placements.

How do you usually supply those to pandoc then, using `-V fontsize=12pt` 
etc. and keep around a bash script for each document? Or do you usually get 
away with writing everything as part of the YAML metadata header?

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4aa5fd58-fe11-49d8-a7bc-07fe7675781d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Workflow for quickly customizing PDF layout
       [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2018-09-06 17:46   ` John MacFarlane
  2018-09-06 23:41   ` John Muccigrosso
@ 2018-09-08 17:36   ` BP Jonsson
  2018-09-08 18:12   ` BP Jonsson
  3 siblings, 0 replies; 13+ messages in thread
From: BP Jonsson @ 2018-09-08 17:36 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 7105 bytes --]

I frequently write short documents in Markdown and convert them to PDF for
printing, usually via XeLaTeX but sometimes via HTML/wkhtmltopdf, and
usually via both my own custom Vim commands and panzer, so that all
extensions and filters I need are run "automatically". I set an environment
variable via [let-modeline.vim][] which is automatically added to
pandoc's/panzer's command line by my Vim wrapper commands so that I only
have to type everything command line related once inside the Markdown
document, and even then I use snippets inside Vim to help with most of the
boilerplate. I also use the evince document viewer which comes with Ubuntu,
which automatically reloads the PDF when it is changed on disk, which is
perhaps the one most important factor for a smooth edit-compile-inspect
workflow. I have tried and abandoned a couple of more feature-laden PDF
viewers which lack automatic reloading. Both XeLaTeX and panzer are rather
slow, as are some of my filters which almost all are JSON filters written
in Perl, but I don't really mind those extra seconds. Because of my
cerebral palsy the most important thing for me is to avoid repetitive
typing and GUI/menu/mouse operations as much as possible. Since typing
itself is slow for me I prefer to spend my typing time editing actual
document content! Vim is a nearly ideal working environment for me --- with
a timeoutlength which would give most non-CP people high blood pressure! :-)
Of course I also use [vim-pandoc][] especially for syntax highlighting and
a lot of snippets and custom Vim commands. As for styling I have a
"metafilter" which takes per-output-format configuration in the YAML
document metadata and injects raw markup around and/or sets attributes in
elements based on existing classes or other attributes. This allows me to
generate both HTML and LaTeX from the same source with similar results,
which is important for me as I'm frequently required to produce both HTML
and PDF versions of the same document. The expectation is probably to
export both from a "word processor" but I refuse to do that! :-) (I'll make
that filter public as soon as I've gotten around to documenting it. I'd
thought I'ld get the time to do that this summer but life had other plans
for me.) I have found that there are things which are easier with (Xe)LaTeX
than with wkhtmltopdf *and vice versa* but the typographical quality of
documents produced with wkhtmltopdf don't quite cut it when you are used to
LaTeX in combination with modern fonts, especially for multilingual
documents.

[let-modeline.vim]:
https://github.com/vim-scripts/let-modeline.vim/blob/master/plugin/let-modeline.vim
[vim-pandoc]: https://github.com/vim-pandoc

Den ons 5 sep 2018 20:09mb21 <mauro.bieg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> I’m interested in learning whether other pandoc users use it to write
> letters or other short documents (i.e. shorter than a thesis) that need to
> be exported to PDF or printed, and what your workflow is like. Let me tell
> you about mine:
>
> I start with writing down the text in a markdown file. This is great,
> because it forces me to focus on the content and prevents me from
> procrastinating by fiddling with the layout of the document.
>
> When I’m done with the content, I choose a template and use pandoc to
> export to PDF. I get a feel of how many pages the text takes and whether I
> should add more paragraphs, subtitles etc. Then comes the time to refine
> the layout for this specific document: add page breaks etc. to avoid widows
> and orphans, or  adjust the font size and margins for very short letters
> that would look lost on a large sheet of paper.
>
> Again, I’m talking relatively short documents here, that contain no
> citations etc. I guess, that’s what most people would use Word for, but I
> just cannot bring myself to use it – bad memories.
>
> I used to export to PDF mostly with LaTeX, but lately I’ve come to use CSS
> (and wkhtmltopdf) more often. For one, because I know CSS by heart, and it
> always takes me too much time to look up how specific LaTeX packages work.
> For another, because I can use the browser’s developer tools to adjust CSS
> and get immediate visual feedback, whereas with LaTeX, compilation usually
> takes a few seconds.
>
> I’ve been experimenting with a few different ways to add those few
> document-specific lines of CSS that override some things in the template.
>
> 1. Copy and customize a pandoc template (but that leaves me with lots of
> template files, in lots of directories, that are almost identical).
> 2. Add a `<style>` tag with the CSS via the `header-includes` variable.
> 3. Add the `<style>` tag directly to the document body.
>
> All of the above are somewhat unsatisfying to me.
>
> Inspired by [CSS-in-JS](
> https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660), I
> was thinking of putting something like the following in a markdown file’s
> YAML metadata:
>
>     ---
>     css:
>       - p:
>           font-size: 30px
>       - li:
>           margin: 20px
>     ---
>
> For this to work with pandoc out of the box, we would have to put
> something like the following in the HTML template, and extend the
> templating language with the `$key` and `$val` constructs:
>
>     <style type="text/css">
>     $for(css)$
>     $key(css)$ {
>       $for(css)$
>       $key(css)$: $val(css)$;
>       $endfor$
>     }
>     $endfor$
>     </style>
>
> So... this turned out to be longer than expected.
>
> Long story short: what do you think? what’s your workflow to quickly and
> painlessly layout shorter documents for PDF export?
>
> --
> 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/784b07a6-19bd-4ddc-9cfb-67440f6becd8%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/784b07a6-19bd-4ddc-9cfb-67440f6becd8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAFC_yuRVvfT4DXFTJshQzx%2B5m%2BH_j9kOfcS0EShqL%2BP4QV-gnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 8978 bytes --]

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

* Re: Workflow for quickly customizing PDF layout
       [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
                     ` (2 preceding siblings ...)
  2018-09-08 17:36   ` BP Jonsson
@ 2018-09-08 18:12   ` BP Jonsson
       [not found]     ` <0659d35a-4f8c-39d2-0998-a02447f5acc7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  3 siblings, 1 reply; 13+ messages in thread
From: BP Jonsson @ 2018-09-08 18:12 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, mb21

Den 2018-09-05 kl. 20:09, skrev mb21:
> 1. Copy and customize a pandoc template (but that leaves me with lots of
> template files, in lots of directories, that are almost identical).
> 2. Add a `<style>` tag with the CSS via the `header-includes` variable.

I prefer a compromise between the two:

Just *after* `header-includes` in your template:

````
if(extra-css)$
<style>
$for(extra-css)$
$extra-css$

$endfor$
</style>
$endif$
````

In your metadata:

````yaml
extra-css:
   # - '.foo { font-family: "Some Font"; }'
   - '.foo { font-family: "Other Font"; }'
````

The point isn't that you save a lot of typing --- because you 
don't and the single quotes or even `` `...`{=html} `` are 
necessary pretty much all around --- but

1. They are independent of header-includes you might include on 
the command line.

2. Unlike header-includes they are format specific, so often no 
need to include `` `...`{=html} `` everywhere or remember to 
comment stuff out if you want to compile with LaTeX as well later.[^1]

2. You can comment out individual lines *in the YAML*, which 
generally is much easier than inserting and removing CSS comment 
markers inside one huge YAML (block) scalar, and they don't even 
show up in the HTML.

[^1]:   FWIW I have something along the lines of these near the 
start and end of both the header and body in my templates:

     ````
     $for(include.header.latex.start)$
     $include.header.latex.start$

     $endfor$
     ````

     You may want to trade in those dots for hyphens, but I find 
the hierarchical/indented structure in the metadata easier to 
navigate.


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

* Re: Workflow for quickly customizing PDF layout
       [not found]     ` <0659d35a-4f8c-39d2-0998-a02447f5acc7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2018-09-10 15:08       ` mb21
  0 siblings, 0 replies; 13+ messages in thread
From: mb21 @ 2018-09-10 15:08 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you BP Jonsson for the detailed write-up! You've certainly given me 
something to think about :-)

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5f27fc46-2b0d-4038-a744-f83404996459%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

end of thread, other threads:[~2018-09-10 15:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05 18:09 Workflow for quickly customizing PDF layout mb21
     [not found] ` <784b07a6-19bd-4ddc-9cfb-67440f6becd8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-09-06 17:46   ` John MacFarlane
     [not found]     ` <m2zhwuy0wo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2018-09-06 18:10       ` John Gabriele
     [not found]         ` <1536257449.4113114.1499279232.7E93AF7A-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
2018-09-06 18:20           ` T. Kurt Bond
2018-09-06 20:05       ` Joseph Reagle
     [not found]         ` <707a6888-0343-05a2-3514-ccb6492caace-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
2018-09-06 20:28           ` T. Kurt Bond
     [not found]             ` <CAN1EhV__kD7JDKdN5q18PWB4TH5Vx3s_ot1JttF2FQFOD1mpfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-06 21:01               ` T. Kurt Bond
2018-09-06 20:34           ` mb21
2018-09-08 10:29       ` mb21
2018-09-06 23:41   ` John Muccigrosso
2018-09-08 17:36   ` BP Jonsson
2018-09-08 18:12   ` BP Jonsson
     [not found]     ` <0659d35a-4f8c-39d2-0998-a02447f5acc7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-10 15:08       ` mb21

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