2

Thanks for making papaja. It's really terrific!

I just submitted my first journal article using it and ran into problems. The layout staff don't know what to do with the code chunks and listings that are fine in single-column, full page format, but not in their 2-column format. I'm trying use the class 'jou' option to make 2 columns, but I can't figure out how to control the size of code and listing fonts (possibly by modifying the css, as recommended here), or how to using the latex package 'listings' to set listings to wrap (as recommended here).

I'd be grateful for any advice, and my apologies if I've missed how one might do this in the documentation.

user20412
  • 193
  • 7
  • Do I understand correctly that you originally submitted a manuscript as a single-column pdf file that looked exactly the way you wanted, but now that you are using the two-column layout (class option `jou`), the code is too wide and is therefore not fully displayed? If so, is it source code (i.e., the content of the code chunk), or R output that is too wide? Moreover, I don't fully understand what is wrong with the display of listings -- it would be great if you could clarify. – Marius Barth Apr 19 '21 at 16:51
  • Yes, that's right. When the layout staff at the journal tried to convert to their format and use 2 columns, they did very strange things with the rmarkdown portions (listings, code, etc.). They converted those to graphics that span the both columns, and it's just generally a mess. They've asked if I can supply a version with 2 columns but with lines wrapping appropriately. So the key thing I need to do is get the latex 'listing' package working with papaja (as it allows code listing lines to wrap). – user20412 Apr 19 '21 at 18:45

1 Answers1

3

If it's only about getting the listings package to work, you can modify the YAML header that it looks similar to the following:

documentclass     : "apa6"
classoption       : "jou"
output            :
  papaja::apa6_pdf:
    pandoc_args: --listings
header-includes:
  - \lstset{breaklines=true}

However, note that using automatic line breaks will most likely break the code at some points. Therefore, it is worthwhile to consider alternatives: For instance, you could try to use a code style that uses more line breaks. The styler package and add-in might be helpful accomplishing this: https://styler.r-lib.org/

Marius Barth
  • 596
  • 2
  • 9
  • Excellent -- this solves the main problem, and I see how styler could help keep things compact -- that's great. Thank you! – user20412 Apr 20 '21 at 19:10