Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Software for typing programming papers

  1. Sep 21, 2011 #1
    Just like there's LaTeX for writing math papers and LaTeX editors to parse it, is there anything for writing papers in programming? Specifically a nice way to automatically format code.
     
  2. jcsd
  3. Sep 21, 2011 #2

    chiro

    User Avatar
    Science Advisor

    Couldn't you use something like notepad++ or some other program that does syntax highlighting and all that jazz and then copy the output and paste it somewhere else?
     
  4. Sep 21, 2011 #3
    The syntax is only highlighted in Notepad++, copying it to another program like Word removes the formatting.
     
  5. Sep 21, 2011 #4

    chiro

    User Avatar
    Science Advisor

    Oh ok that sucks. When you copy code in MATLAB it preserves the formatting and color/indentation information.

    There was to be some editor out there that preserves this information when it's copied!
     
  6. Sep 22, 2011 #5

    diazona

    User Avatar
    Homework Helper

    You mean copying from one MATLAB window to another, or copying from MATLAB to another program? If the former case, it's not actually preserving the information, it's just re-formatting it in the new window.

    Anyway, automatically formatting code is not on the same level as typesetting math. Source code itself is just text, so you can type it just fine in LaTeX or anything else. Syntax highlighting and indentation and such things are just little tweaks that you can do to make the code a little more readable, kind of akin to fixing up the spelling and grammar of something you wrote and adding italics to emphasize key words. You wouldn't expect LaTeX or any other writing software to do those sorts of things automatically. In contrast, typesetting math is actually impossible with a regular text editor or word processor. You need a special system, which is what LaTeX provides.

    I ran a Google search for latex code and here's the first thing that popped up: http://scott.sherrillmix.com/blog/programmer/displaying-code-in-latex/
     
  7. Sep 22, 2011 #6
    If this is true, this may be an indication that Notepad++ is atrocious.

    If I copy from Visual Studio or http://www.flos-freeware.ch/notepad2.html" [Broken] into Word, formatting is transferred.
     
    Last edited by a moderator: May 5, 2017
  8. Oct 3, 2011 #7
    In LaTeX you can use the "listings" package. Here is a nice and concise description:
    http://texblog.wordpress.com/2008/04/02/include-source-code-in-latex-with-listings/" [Broken]
     
    Last edited by a moderator: May 5, 2017
  9. Oct 3, 2011 #8

    diazona

    User Avatar
    Homework Helper

    Actually, it's an indication that Notepad++ is good, since it's doing exactly what it's supposed to do. When I copy from a text editor and paste into another program, I expect that all I will be copying is text. Sure, sometimes copying with syntax highlighting is a useful feature, but that could be enabled with a special copy command on the Edit menu, or perhaps through the Paste Special feature in Word (I'm not sure if it works that way).

    In any case, Notepad++ is widely considered to be one of the best text editors available for Windows. I've used it myself and I completely agree, it's great.
     
  10. Oct 3, 2011 #9

    jhae2.718

    User Avatar
    Gold Member

    Listings works really well.
     
    Last edited by a moderator: May 5, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook