rootstock
rootstock copied to clipboard
Page number, line number, double spacing
Most journals have some requirements like page number, continuous line number and double spacing. Is it possible to add these features for pdf export?
Regarding line spacing in the PDF, this is possible. See this tweet thread / https://github.com/zach-hensel/low-noise-manuscript/commit/a99ae5f6db0f2fba08af1138255c969183696557. @vincerubinetti what's the best way currently to get double spacing just for the PDF?
Line numbering in the PDF would be great. Not sure if this is feasible. @vincerubinetti?
Regarding page numbering, it seemed that there may be okay CSS solutions. It's possible we could number pages after exporting to PDF with a solution like this or these.
If we get a nice implementation of page numbering or line numbering, we should consider adding them to rooststock.
@vincerubinetti what's the best way currently to get double spacing just for the PDF?
In build/themes/default.html
:
Adjust to your desired height. Unfortunately just setting it to 2
doesn't really end up looking like double space due to font and CSS oddities. 2.5
will probably look more like double space.
Line numbering in the PDF would be great. Not sure if this is feasible
If you mean line numbering for code blocks, then it's probably possible. If you mean line numbering for just regular paragraphs, whose wrapping is dynamic and can change, that's almost surely not possible, even with javascript.
Ah okay so:
https://github.com/manubot/rootstock/blob/ed4158c9f2a1b300f82d058be9aefe1f5eb72763/build/themes/default.html#L502
This previous should work once I move this issue to the manubot/rootsock
repo.
If you mean line numbering for just regular paragraphs, whose wrapping is dynamic and can change, that's almost surely not possible, even with javascript.
Yes, it would be like in this pdf. I guess the idea would be that the numbers get added after the dynamic line wrapping has occurred.
A straightforward way of page numbering:
pspdftool 'number(x=-1pt,y=-1pt,start=1,size=10)' output/manuscript.pdf output/manuscript_num.pdf
But this method breaks all links :/ Useless.
A straightforward way of page numbering: But this method breaks all links
Ah too bad. I like the approach. pspdftool appears to be stagnant (no updates since 2015), so perhaps right approach but wrong tool?
Another workaround with three dependencies: pdftk
, ps2pdf
and enscript
.
- Create a bash file named
build/pagenum.sh
- Content of the bash file:
#!/bin/bash
input="$1"
output="${1%.pdf}-num.pdf"
pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2)
enscript -L1 --header='|| $%/$=' --output - < <(for i in $(seq "$pagenum"); do echo; done) | ps2pdf - | pdftk "$input" multistamp - output $output
- Add the following line in the
build.sh
bash build/pagenum.sh output/manuscript.pdf
The page-numbered output file will be output/manuscript-num.pdf
.
It is kind of ugly that page numbers are in the header. I am sure this can be improved.
Hello @adebali and @dhimmel , any updates on that? Or is the pdftk + ps2pdf + enscript the current best approach?
@lubianat no one has been actively working on this, so the pdftk + ps2pdf + enscript approach is still the best I'm aware of. We welcome improved suggestions if you or anyone else have ideas.
Thanks, @agitter . I ended up compiling the docx via Manubot and adding line and page numbers in LibreOffice (here is the docx, by the way).
It is not perfect, but also not a big trouble. Way better than writing it all in Word or dueling with latex compilation.
I wonder if it is possible to do LibreOffice macros. Maybe that would be a semi-automatic option.