Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page number, line number, double spacing #244

Open
adebali opened this issue Jul 3, 2019 · 10 comments
Open

Page number, line number, double spacing #244

adebali opened this issue Jul 3, 2019 · 10 comments
Labels
frontend issues related to the HTML view and interactivity

Comments

@adebali
Copy link
Contributor

adebali commented Jul 3, 2019

Most journals have some requirements like page number, continuous line number and double spacing. Is it possible to add these features for pdf export?

@dhimmel
Copy link
Member

dhimmel commented Jul 3, 2019

Regarding line spacing in the PDF, this is possible. See this tweet thread / zach-hensel/low-noise-manuscript@a99ae5f. @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
Copy link
Collaborator

@vincerubinetti what's the best way currently to get double spacing just for the PDF?

In build/themes/default.html:

image

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.

@dhimmel
Copy link
Member

dhimmel commented Jul 3, 2019

Ah okay so:

line-height: 1.35;

This previous should work once I move this issue to the manubot/rootsock repo.

@dhimmel dhimmel transferred this issue from manubot/manubot Jul 3, 2019
@dhimmel
Copy link
Member

dhimmel commented Jul 3, 2019

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.

@adebali
Copy link
Contributor Author

adebali commented Feb 15, 2020

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.

@dhimmel
Copy link
Member

dhimmel commented Feb 15, 2020

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?

@adebali
Copy link
Contributor Author

adebali commented Feb 16, 2020

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.

@dhimmel dhimmel added the frontend issues related to the HTML view and interactivity label Mar 5, 2020
@lubianat
Copy link
Contributor

lubianat commented Dec 9, 2020

Hello @adebali and @dhimmel , any updates on that? Or is the pdftk + ps2pdf + enscript the current best approach?

@agitter
Copy link
Member

agitter commented Dec 20, 2020

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

@lubianat
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend issues related to the HTML view and interactivity
Projects
None yet
Development

No branches or pull requests

5 participants