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
  • 1
    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
  • thanks Flyto that's a sensible answer! – gaspar Oct 20 '19 at 6:54

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.

  • 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

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.