开发者

How to "Export" code the right way?

I have a project in Java and I need to make a code listing in part of my LaTeX documentation with all my classes and code. What is the best way to export the code? Is it simply just copy and paste, or is there 开发者_JAVA百科a way to export the code properly to keep all the formatting?


It's easy enough to do:

for d in `find <projectdir> -name '*.java'; do
    echo "$d" >> output.txt
    cat "$d" >> output.txt
done

...but what possible purpose could dumping all the code into a document serve?


If LaTeX is the target, I'd search for some formatting templates for code. It's easy enough to get text into LaTeX, but the formatting will be a different matter.


I found a way: http://texblog.wordpress.com/2008/04/02/include-source-code-in-latex-with-listings/

although, this way the code seems to run off the page..


You can also try the package listings you mention directly within Eclipse with the TEXlipse plugin

How to "Export" code the right way?


(source: sourceforge.net)

You can then see if you reference the right Java files in your references.
Used in this tutorial slide 19.


You can also try :

  • GNU source-highlight, which can produce Latex output, and may be more appropriate for batch processing a all lot of files.
  • pygmentize, which needs Python, and should also produce Latex output.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜