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.)

EDIT: The original question referred to the 6th edition of the APA manual. As HumberSean answered, computer code style is now specified in the 7th edition.

  • 2
    Probably you want to communicate with the journal editor.
    – puppetsock
    Oct 18, 2019 at 18:27
  • 6
    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, 2019 at 23:45

4 Answers 4


APA 7 provides for computer code: "To present computer code, use a monospace font such as 10-point Lucida Console or 10-point Courier New."

For my APA 6 thesis, I used italics for my coding examples following APA 6 4.20 (a letter, word, or phrase cited as a linguistic example), taking the position that JavaScript is a language.


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."

  • 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, 2020 at 12:40

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, 2019 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, 2019 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, 2019 at 12:11

Another option is to put code in a figure with monospaced font and with syntax highlighting. I ended up using Consolas 8pt in my figures.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .