nmfs-opensci / quarto_titlepages

A Quarto extension for making title and cover pages for PDF output.
https://nmfs-opensci.github.io/quarto_titlepages/
Creative Commons Zero v1.0 Universal
115 stars 20 forks source link

New line/break in coverpage blocks #48

Closed leonhead-acer closed 6 months ago

leonhead-acer commented 9 months ago

Hello

I've been trying to introduce a new line/line break into the coverpage fields, but nothing seems to work. I've tried all of the options listed here: https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines?rq=2

Any advice on this would be much appreciated :)

eeholmes commented 9 months ago

This?

    coverpage-title: |
      Otters\
      Are Cute\

which achieves this

image
leonhead-acer commented 9 months ago

Thank you for the quick reply. Oh yes, this works in the coverpage-title field. I have a few subtitles for my cover page, I was trying to include them in other fields like author and footnote but that format doesn't work in those fields.

What is the best way to handle a subtitle on the cover page? The subtitle text is smaller font than the title text - I've seen you can change the size of text within a YAML field here: https://stackoverflow.com/questions/44008828/r-markdown-format-title-pdf-output

So something like this - although this doesn't work for me using your extension:

   coverpage-title: | 
      | \LARGE Otters
      | \Large Are Cute

It would be good to be able to change the font size, and apply bold/italics if possible :)

eeholmes commented 9 months ago

Did you see the "great wave" example where I use the footer element to create a subtitle?

https://nmfs-opensci.github.io/quarto_titlepages/05-coverpage-themes.html#great-wave-1

    coverpage-title: |
      Otters\
      Are Cute\
    coverpage-footer: |
      and sea otters\
      are even cuter!\
    coverpage-theme:
      title-color: "white"
      title-fontfamily: "QTDublinIrish.otf"
      title-fontsize: 100
      author-style: "plain"
      author-sep: "newline"
      author-fontstyle: "textsc"
      author-fontsize: 30
      author-align: "right"
      author-bottom: "2in"
      header-style: "none"
      date-style: "none"
      footer-style: "plain"
      footer-color: "white"
      footer-fontsize: 20
      footer-fontfamily: "QTDublinIrish.otf"
      footer-align: "right"
      footer-bottom: "6.5in"
      keep-tex: true
eeholmes commented 9 months ago

Result is this

image
leeroyaus commented 9 months ago

When replicating your code above I don't see any cover page (I think coverpage field needs to be specified?).

When specifying the coverpage field, that's when it breaks for me. It works when coverpage: otter but when coverpage: great-wave or coverpage: true it doesn't work for me

Error message is below (I'm also using this in a Quarto book project):

Error running filter C:/PROGRA~1/Quarto/share/filters/main.lua:
...e\_extensions\nmfs-opensci\titlepage\coverpage-theme.lua:271: bad argument #1 to 'for iterator' (table expected, got nil)
stack traceback:
    ...e\_extensions\nmfs-opensci\titlepage\coverpage-theme.lua:271: in function <...e\_extensions\nmfs-opensci\titlepage\coverpage-theme.lua:47>
    [C]: in ?
    [C]: in method 'walk'
    C:/PROGRA~1/Quarto/share/filters/main.lua:171: in function 'run_emulated_filter'
    C:/PROGRA~1/Quarto/share/filters/main.lua:449: in local 'callback'
    [string "..."]:1789: in field 'withScriptFile'
    C:/PROGRA~1/Quarto/share/filters/main.lua:452: in upvalue 'run_emulated_filter_chain'
    C:/PROGRA~1/Quarto/share/filters/main.lua:495: in function <C:/PROGRA~1/Quarto/share/filters/main.lua:476>
stack traceback:
    C:/PROGRA~1/Quarto/share/filters/main.lua:171: in function 'run_emulated_filter'
    C:/PROGRA~1/Quarto/share/filters/main.lua:449: in local 'callback'
    [string "..."]:1789: in field 'withScriptFile'
    C:/PROGRA~1/Quarto/share/filters/main.lua:452: in upvalue 'run_emulated_filter_chain'
    C:/PROGRA~1/Quarto/share/filters/main.lua:495: in function <C:/PROGRA~1/Quarto/share/filters/main.lua:476>
leeroyaus commented 9 months ago

(Sorry, leeroyaus is my other github account)

eeholmes commented 9 months ago

Here is my full format spec

format: 
  titlepage-pdf:
    documentclass: scrbook
    classoption: ["oneside", "open=any"]
    number-sections: true
    toc: true
    lof: true
    lot: true
    titlepage: "bg-image"
    titlepage-theme:
      elements: ["\\titleblock", "\\authorblock", "\\vfill", "\\dateblock", "\\affiliationblock",  "\\logoblock", "\\footerblock"]
    titlepage-bg-image: "img/corner-bg.png"
    titlepage-logo: "img/logo.png"
    titlepage-header: "The Publisher"
    titlepage-footer: |
      NOAA Fisheries OpenSci\
      Tools for Open Science\
      [https://github.com/nmfs-opensci](https://github.com/nmfs-opensci)\
    coverpage-include-file:
      - tex/copyright.tex
    titlepage-include-file:
      - tex/dedication.tex
    coverpage: true
    coverpage-bg-image: "img/otter-bar.jpeg"
    coverpage-title: |
      Otters\
      Are Cute\
    coverpage-footer: |
      and sea otters\
      are even cuter!\
    coverpage-author: ["EE", "Holmes"]
    coverpage-theme:
      title-color: "white"
      title-fontfamily: "QTDublinIrish.otf"
      title-fontsize: 100
      author-style: "plain"
      author-sep: "newline"
      author-fontstyle: "textsc"
      author-fontsize: 30
      author-align: "right"
      author-bottom: "2in"
      header-style: "none"
      date-style: "none"
      footer-style: "plain"
      footer-color: "white"
      footer-fontsize: 20
      footer-fontfamily: "QTDublinIrish.otf"
      footer-align: "right"
      footer-bottom: "6.5in"
      keep-tex: true
eeholmes commented 9 months ago

works with coverpage: great-wave also

eeholmes commented 9 months ago

Here is a repo of a Quarto book using the titlepages-pdf format. This works for me.

https://github.com/eeholmes/test_quarto-titlepages

leeroyaus commented 9 months ago

Here is my full format spec

format: 
  titlepage-pdf:
    documentclass: scrbook
    classoption: ["oneside", "open=any"]
    number-sections: true
    toc: true
    lof: true
    lot: true
    titlepage: "bg-image"
    titlepage-theme:
      elements: ["\\titleblock", "\\authorblock", "\\vfill", "\\dateblock", "\\affiliationblock",  "\\logoblock", "\\footerblock"]
    titlepage-bg-image: "img/corner-bg.png"
    titlepage-logo: "img/logo.png"
    titlepage-header: "The Publisher"
    titlepage-footer: |
      NOAA Fisheries OpenSci\
      Tools for Open Science\
      [https://github.com/nmfs-opensci](https://github.com/nmfs-opensci)\
    coverpage-include-file:
      - tex/copyright.tex
    titlepage-include-file:
      - tex/dedication.tex
    coverpage: true
    coverpage-bg-image: "img/otter-bar.jpeg"
    coverpage-title: |
      Otters\
      Are Cute\
    coverpage-footer: |
      and sea otters\
      are even cuter!\
    coverpage-author: ["EE", "Holmes"]
    coverpage-theme:
      title-color: "white"
      title-fontfamily: "QTDublinIrish.otf"
      title-fontsize: 100
      author-style: "plain"
      author-sep: "newline"
      author-fontstyle: "textsc"
      author-fontsize: 30
      author-align: "right"
      author-bottom: "2in"
      header-style: "none"
      date-style: "none"
      footer-style: "plain"
      footer-color: "white"
      footer-fontsize: 20
      footer-fontfamily: "QTDublinIrish.otf"
      footer-align: "right"
      footer-bottom: "6.5in"
      keep-tex: true

In my cover page there will just be title and footer (with footer technically a subtitle). When I try to remove the author field from the coverpage I get the same error as before. Is this expected?

eeholmes commented 9 months ago

Hmm, that's a bug. But you can easily remove the author. Use

author-style: "none"

in the coverpage-theme section of the yaml.

leeroyaus commented 9 months ago

Thank you very much, that is working for me now :)

leeroyaus commented 9 months ago

Actually no, the author is still appearing - it was just black font on a black background. Here's a zoomed in image: image

format:
  titlepage-pdf:
    documentclass: scrbook
    classoption: ["oneside", "open=any"]
    number-sections: true
    toc: true
    lof: true
    lot: true
    titlepage: "bg-image"
    titlepage-theme:
      elements: ["\\titleblock", "\\authorblock", "\\vfill", "\\dateblock", "\\affiliationblock",  "\\logoblock", "\\footerblock"]
    titlepage-bg-image: "img/corner-bg.png"
    titlepage-logo: "img/logo.png"
    titlepage-header: "The Publisher"
    titlepage-footer: |
      NOAA Fisheries OpenSci\
      Tools for Open Science\
      [https://github.com/nmfs-opensci](https://github.com/nmfs-opensci)\
    coverpage-include-file:
      - tex/copyright.tex
    titlepage-include-file:
      - tex/dedication.tex
    coverpage: true
    coverpage-bg-image: "img/otter-bar.jpeg"
    coverpage-title: |
      Otters\
      Are Cute\
    coverpage-footer: |
      and sea otters\
      are even cuter!\
    coverpage-author: ["EE", "Holmes"]
    coverpage-theme:
      title-color: "white"
      title-fontfamily: "QTDublinIrish.otf"
      title-fontsize: 100
      author-style: "none"
      header-style: "none"
      date-style: "none"
      footer-style: "plain"
      footer-color: "white"
      footer-fontsize: 20
      footer-fontfamily: "QTDublinIrish.otf"
      footer-align: "right"
      footer-bottom: "6.5in"
      keep-tex: true
eeholmes commented 9 months ago

Ok, that is definitely a bug. I will fix. In the meantime you can get rid of the author with

     coverpage-author: ""
eeholmes commented 9 months ago

Ok, hopefully it should work now. I posted a new release. To update use. Problem was with the lua filter that was overriding the author style if coverpage: true.

quarto install extension nmfs-opensci/quarto_titlepages
leeroyaus commented 8 months ago

Thank you that is working for me now :)