Search code examples
r-markdownpapaja

Adding preamble.tex and/or modifying css


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.


Solution

  • 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/