Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 a way to export the code properly to keep all the formatting?

like image 442
KP65 Avatar asked Oct 15 '22 06:10

KP65


2 Answers

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?

like image 124
Tomislav Nakic-Alfirevic Avatar answered Nov 01 '22 11:11

Tomislav Nakic-Alfirevic


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.

like image 35
duffymo Avatar answered Nov 01 '22 09:11

duffymo