This package uses Latex to generate a PDF containing some file's code and output.
The result looks similar to that produced by MATLAB's publish
function.
This is particularly useful if you have to submit code with problem sets.
To install, enter Julia and run the following:
Pkg.clone("https://github.com/dressel/Publish.jl.git")
using Publish
publish("code.jl")
Currently, this will generate a PDF called "code.pdf" that contains the code, any printed output, and any plots generated by the code. The output and plots are generated by running the code itself. Plotting is currently handled with PGFPlots.jl.
If you just want to print the code without running it, specify the optional runcode
parameter:
publish("code.jl", runcode=false)
Plotting is currently handled with the Julia PGFPlots package.
Any time you use the save
function with PGFPlots, that plot is saved to the PDF.
listings
to plot the codecaption
forgot why we need thisstandalone
for plotsxcolor
for pgfplots, listings stuffpgfplots
for plottinggeometry
to change margins
An example file named sample_file.jl and its corresponding pdf can be found in the examples folder. To try generating this on your own, run the code below. It will copy the sample file to your current directory (with the name publish_package_sample.jl to avoid any potential conflicts). You should then be able to publish the code.
require(Publish/examples/copy_sample.jl")
using Publish
publish("publish_package_sample.jl")
If you publish a file in another folder, as in:
publish("folder/file.jl")
This will put the pdf and tex file in the directory named folder
.
Any time you publish a file, a .pdf and a .tex file will be saved.
Any time your code saves a plot (using PGFPlots), a .tex file will be saved for it.
- Make some test julia files and stick them in the test folder
- Allow publishing of other languages (obviously, can't run that code)
- Include another publishing format that doesn't rely on Latex (md, html)
- improve listings language file (in julia_listings.tex)
- Robust to not having things like pgfplots. Just don't plot in that case
- Override display, so printing arrays can look pretty
- Make the Output style look better
- If a file includes another file, should that file be displayed too?