Search code examples
yamllatexr-markdownquarto

How to retrieve multiple author name parts separately in a latex template


I try to write a report in quarto with _quarto.yml:

project:
  type: book

book:
  title: 'More of the same'
  author:
  - given-names: Ben
    surname: Fretwurst
  - given-names: Dirk 
    surname: Ursen

  chapters:
    - index.qmd

format:
  pdf:
    documentclass: scrreport
    template: files/Template.tex

In the footnote of the LaTeX-template, I try to get only the surnames:

 {$for(by-author)$ {$by-author.surname.literal$} $sep$/ $endfor$}

And on the Titlepage the full names:

$for(by-author)$ $by-author.given-names.literal$ $by-author.surname.literal$ $sep$ and $endfor$ 

With that code, it only shows the separators in the pdf.


Solution

  • The "by-author" was to much and ".literal" is not needed too.

    So the correct syntax is in the template:

    {$for(author)$ {$author.surname$} $sep$/$endfor$}

    And it gets even better: You can use given-names or affiliation after "author." Or you invent your own identifiers, like author.title or (if its relevant for you) the zodiac-sign. So you can write in the yaml:

    book:
      title: 'More of the Same'
      author:
      - given-names: Ben
        surname: Fretwurst
        title: Dr.
        zodiac-sign: Leo
      - given-names: Ursina 
        surname: Ursen
        zodiac-sign: Twins
    

    and in your LaTeX-Template for the footnote:

    $for(author)$ {$author.surname$} $sep$/ $endfor$
    

    becomes in the footnote: only surnames of the authors

    and for the titlepage:

    $for(author)$ $if(author.title)$$author.title$$endif$ $author.given-names$ $author.surname$ $if(author.zodiac-sign)$($author.zodiac-sign$)$endif$ $sep$ and $endfor$
    

    title given-name and surname of the authors