Pandoc markdown - multiple authors with affiliation side-by-side in PDF?
Asked Answered
B

1

7

I am using pandoc 2.10. I would like to write an article document in Markdown, then export to PDF via latex - and I would like to have multiple authors with affiliation and email underneath, somewhat like this example from https://mcmap.net/q/1626661/-multiple-authors-and-subtitles-in-rmarkdown-yaml (that however uses R-specific template, apparently) :

enter image description here

So, first I try with the default pandoc capabilities - this is test.md:

---
title: "Testing the authors"
author:
  - Alice Alisson, First, Oldest Institute
  - Bob Bobson, First, Oldest Institute
  - Charlie Charlson, Second, Newer Company
date: Aug 10, 2020
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Using pandoc test.md --pdf-engine=xelatex -o test.pdf, I get:

plain-test

Like this, authors are not side by side - and affiliations are next to the author name; and since the institutions' names also have a comma, it gets a bit confusing to read that.

Then, I found one can use affiliations via footnote in plain pandoc - here is updated test.md:

---
title: "Testing the authors"
author:
- Alice Alisson^[First, Oldest Institute]
- Bob Bobson^[First, Oldest Company]
- Charlie Charlson^[Second, Newer Company]
date: Aug 10, 2020
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

... and with pandoc test.md --pdf-engine=xelatex -o test.pdf, I get:

enter image description here

Authors are side-by-side, which is great, but affiliations are footnotes, which I do not like.

Then, via Authors and affiliations in the YAML of RMarkdown - I found about https://github.com/pandoc/lua-filters ; so thought I could test that; so here is updated test.md:

---
title: "Testing the authors"
institute:
  - first: First, Oldest Institute
  - second: Second, Newer Company
author:
  - Alice Alisson:
      institute:
        - first
      correspondence: "yes"
      email: [email protected]
  - Bob Bobson:
      institute:
        - first
      correspondence: "yes"
      email: [email protected]
  - Charlie Charlson:
      institute:
        - second
      correspondence: "yes"
      email: [email protected]
date: Aug 10, 2020
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

... and with: pandoc test.md --lua-filter=scholarly-metadata.lua --lua-filter=author-info-blocks.lua --pdf-engine=xelatex -o test.pdf, I get:

enter image description here

So, here, authors are side-by-side, which is great - but I get the affiliation via references like footnotes, and the e-mails are also in a separate line; I find this kinda hard to read.

So, how can I format a YAML block for a pandoc document, so that it shows the authors side-by-side, with affiliation and e-mail underneath? Something like:

    Alice Alisson               Bob Bobson             Charlie Charlson                      
First, Oldest Institute   First, Oldest Institute    Second, Newer Company      
    [email protected]            [email protected]            [email protected]                    

If this is not possible with plain pandoc - are there any lua filters that I could use to achieve this?

Boraginaceous answered 10/8, 2020 at 9:57 Comment(0)
E
3

One can combine the scholarly-metadata.lua filter with a custom filter which squashes the author entries in the desired way:

-- file: format-authors.lua
local function squash_author (institutes)
  return function (author)
    local name = setmetatable(author.name, {})
    local institute = institutes[tonumber(author.institute[1])]
    return pandoc.MetaInlines(
      pandoc.List(name)
        .. pandoc.List{pandoc.LineBreak()}
        .. pandoc.List(institute.name)
        .. pandoc.List{pandoc.LineBreak()}
        .. author.email
    )
  end
end

function Meta (m)
  m.author = m.author:map(squash_author(m.institute))
  return m
end

Processing the example given above with

pandoc test.md \
   --lua-filter=scholarly-metadata.lua \
   --lua-filter=format-authors.lua 
   -o test.pdf

produces

generated PDF

You'd have to also adjust the font size used for authors to get all authors in a single row.

Ethnology answered 12/8, 2020 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.