Make an abstract booklet with R and LaTeX

[This article was first published on R – scottishsnow, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Last week I co-ran the FOSS4GUK conference in Edinburgh. It was great fun and thoroughly exhausting. Part of the preparation work I did was to produce an abstract booklet for the conference. This post is a guide to how I automated that with R and LaTeX.

R is a programming language focused on data analysis and LaTeX is a document preparation system. Both are open source. I used R to process and clean abstracts and LaTeX to type set the booklet, based on a template I found on Overleaf.

With hindsight I wish we had required speakers to submit abstract text in a form, but we allowed them to upload files. This lead to a tedious amount of copy and pasting from pdf, word and plain text. Once this was over I set up a delegates file with the following columns:

  • name
  • join
  • day
  • time
  • room
  • title
  • affiliation

I populated it from the conference programme.

Next I used R to read each abstract file and join it to the delegate meta data. Each abstract was then written out to a new file in the format for the LaTeX document. Finally a list of these LaTeX ready abstracts was made:


f = list.files("~/Cloud/Michael/FOSS4G/talks/abstracts_clean")

meta = read_csv("~/Cloud/Michael/FOSS4G/talks/abstract_book/talk_names.csv") %>%

lapply(f, function(i){
   x = read_file(paste0("~/Cloud/Michael/FOSS4G/talks/abstracts_clean/", i))
   y = str_remove(i, ".txt")
   z = filter(meta, join == y)

   fileConn = file(paste0("~/Cloud/Michael/FOSS4G/talks/abstract_book/abstracts/", i))
   writeLines(c(paste0("\\begin{conf-abstract}[", z$day, "\\", str_sub(z$time, 1, 5), "\\", z$room, "]"),
                paste0("{", z$title, "}"),
                paste0("{", z$name, "}"),
                paste0("{", z$affiliation, "}"),


f = list.files("~/Cloud/Michael/FOSS4G/talks/abstract_book/abstracts/")

fileConn = file("~/Cloud/Michael/FOSS4G/talks/abstract_book/abstracts_list.txt")
writeLines(paste0("\\input{abstracts/", f, "}"),

There’s a but here. LaTeX requires \\ for a new line, but R uses regex which makes the first \ an escape sequence to print the second \. No doubt there’s some bash wizardry I could use to replace these (comments welcome), but I resorted to a find and replace in a text editor as I was on a rush to get the booklet finished! Here’s a list of characters/strings I had to replace and what I replaced them with:

  • $ | \$
  • % | \%
  • _ | \_
  • & | \&
  • [Thu\ | [Thu\\
  • [Fri\ | [Fri\\
  • \Green] | \\Green]
  • \Blue] | \\Blue]

There were also some oddly encoded ' from word (no surprise), which needed to be swapped. LaTeX likes “quotes” to be formatted like “quotes”, which are then rendered beautiful – I had to manually fix these.

Finally I ran the LaTeX compiler, after I’d added the abstract list to the following.





    { \renewcommand\textsuperscript[1]{}
      {\texorpdfstring{#2 (\emph{#3})}{#2 (#3)}}
    {{\large\bfseries #2}\marginnote{#1}\par}
    {\small #4\par}





        Conference Abstracts\\
    \includegraphics[width=8cm]{../../logos/[email protected]} % also works with logo.pdf





% Specify conf-abstract like this:
% \begin{conf-abstract}[optional text going into the margin note]
% {Title of Paper}
% {Authors (use \textsuperscript as institution markers)}
% {Institutions (use \textsuperscript as institution markers)}
% \indexauthors{Lastname1!Firstname 1, Lastname2!Firstname2}
% Abstract text
% \end{conf-abstract}
% It's probably best to generate the abstracts from a
% database or something via a script. Don't forget to
% check through for any special characters that need to
% be escaped.




If I had more time I would play about with fonts, colours and automate some of the string replacement.


To leave a comment for the author, please follow the link and comment on their blog: R – scottishsnow. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)