5

I'm working on a paper for IEEE Transactions on Computers, and I can't find any guidelines on how to format code (C++) that is included in the paper.

I found some other papers with short code snippets, and it looks like they just used Courier New for the font, but I'm not sure of the font size. Do I need to include line numbers? I haven't found any with long sections of code (so for something with 4 lines I wouldn't expect line numbers anyways).

If someone has published a paper with code in it in IEEE Trans, and could give me some advice, I would really really appreciate it.

5

The IEEE does not generally have any strict guidelines on how to format code for papers in their journals or conferences, so you have some freedom of choice in how you do so. The general guideline is simply to use a monospace font and formatting choices that are not blatantly incompatible with the rest of the paper.

Now, if you are writing for IEEE, you should probably be using LaTeX. This means that there are a number of excellent packages, such as these, that will format your code in a nice and professional manner that is generally quite familiar to IEEE reviewers and editors. If you pick one and use that, you should not expect any problems.

  • My supervisor is unfortunately very opposed to LaTeX due to the difficulty in exchanging feedback and tracking changes, which is why I'm stuck with Word for the time being. I use LaTeX when I write up labs for my class, and I really like the options and appearance. Thank you for the information, though. I will stick with Courier New for now and maybe try to switch to TeX again, though that has never gone well so far. – Mewa Mar 2 '15 at 21:00
  • 5
    @Mewa: Not that it sounds like it would convince your supervisor, but: Unlike Word documents, LaTeX source code can be properly used and merged with versioning systems (something you should be familiar with anyway if you are publishing papers with code), in particular, if you adhere to the simple rule of using one line per sentence. Rendering nice can be as easy as latexdiff-svn -r 42 paper.tex --pdf. You can exchange feedback by just changing what you think should be changed, your collaborator silently accepts what they agree on and the you discuss everything else. – Wrzlprmft Mar 2 '15 at 21:45
  • You can also use LaTeX to prepare the code as as figure images for inclusion in your Word document. But, PS: your supervisor is wrong. – jakebeal Mar 2 '15 at 22:31
  • 1
    Just as an update, I wrote it in LaTeX, and the code looked beautiful. The paper, however, got rejected on the grounds of having too much code (which I agree with), so there is that. – Mewa May 1 '15 at 21:03
  • Unfortunately the ieeetrans latex templates make the use of algorithmic latex templates very complicated. – metamorphosis Jun 2 '16 at 4:18
2

Word's style definitions are really useful in situations like this. As long as everyone is using Word 2007+, one person could set up what code ought to look like (e.g., +1 left indent, +1 right indent, Courier New, single space, do not spell check, etc.) and save it as "CodeSnippet" or a similar style by highlighting some of the text, right clicking, and looking under the "Style" sub-menu for "Save selection as new Quick Style." Saving it to that document (rather than a template) will at least keep a consistent code style in everyone's document. It's also a little easier to go back and "clean up" someone else's code later (highlight it, click the code style in the Quick Styles bar) or modify the style rules for all instances of code later on in revision.

One caveat: aside from the style definitions common to all general use word processors (like blue-text + underline "HTML Link" style), I've never seen user-defined styles make the jump between Word and anything else (or vice versa).

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.