Skip to content

Julia package for publishing code. Uses Latex to create a pdf with your code and output.

License

Notifications You must be signed in to change notification settings

dressel/Publish.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Publish

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.

Installation

To install, enter Julia and run the following:

Pkg.clone("https://github.com/dressel/Publish.jl.git")

Basic Usage

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

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.

Required Tex Packages

  • listings to plot the code
  • caption forgot why we need this
  • standalone for plots
  • xcolor for pgfplots, listings stuff
  • pgfplots for plotting
  • geometry to change margins

Example File

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")

Notes

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.

TODO list

  • 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?

Build Status

About

Julia package for publishing code. Uses Latex to create a pdf with your code and output.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published