2

If a psychological methods journal only specifies that the entire manuscript has to be in APA style, how should I format computer code snippets in the manuscript to be submitted? I see nothing mentioned in the actual APA manual regarding this.

Is there any convention? In specific I wonder whether or not I should include syntax highlighting.

(The code currently in question is R, but it could also be, say, Python or JavaScript.)

  • 1
    Probably you want to communicate with the journal editor. – puppetsock Oct 18 '19 at 18:27
  • 2
    If the APA manual does not specify how to format code, then you can't "format code in APA style". Unless the journal has any specific policy, the answer is probably "it doesn't matter, so long as it's sensible and consistent". You could ask the editor, as puppetsock suggests, but I really wouldn't worry about it. – Flyto Oct 18 '19 at 23:45
1

I’m not certain if there’s an official method of formatting code that’s included in the paper itself, but there’s a simple workaround:

Put your code on a website like GitHub, then cite that website the same way you’d cite any other website in the APA style whenever you refer to the elements of the code you’ve posted on that site.

|improve this answer|||||
  • okay yeah, this may be reasonable for most cases, but my current specific paper is a tutorial and like half the paper is code snippets (ca. 1 snippet after each text paragraph)... so it doesn't really work to replace half the paper with a bunch of links – gaspar Oct 20 '19 at 6:52
  • @Gaspar Not links, citations. You’d be saying “(Gaspar, 2019)” a lot, with the link to the website being in the references. But also, I’m not certain how much guidance that the APA standard would provide for formatting code in a research paper because the APA is the American Psychological Association, so I doubt that they’d have many research papers that include code published in their journals. – nick012000 Oct 20 '19 at 21:08
  • yeah that's similar anyway. and yeah not usual but there are many instances in boundary areas with computing and methods. anyway, Flyto's comment is probably the best answer in the end – gaspar Oct 21 '19 at 12:11
1

Did you find a working solution? I am in the same position; most of my paper is about code and the output it generates.

Psychological methods (an APA journal) has some instructions about this here: "If you would like to include code in the text of your published manuscript, please submit a separate file with your code exactly as you want it to appear, using Courier New font with a type size of 8 points. We will make an image of each segment of code in your article that exceeds 40 characters in length. (Shorter snippets of code that appear in text will be typeset in Courier New and run in with the rest of the text.) If an appendix contains a mix of code and explanatory text, please submit a file that contains the entire appendix, with the code keyed in 8-point Courier New."

|improve this answer|||||
New contributor
JCR is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Cool, it's nice that they give guidelines about this; most journals don't. I eventually followed Flyto's comment, so I basically just simply formatted all code in Courier New with no highlights, and (when not in-line with normal text) font size 11 and 1.15 line spacing. It's fairly arbitrary, but I think it looks decent enough. – gaspar Apr 4 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.