Pythontex and Julia


Pythontex provides very nice support for typesetting documents with Julia code embedded—however, it does not support the Julia console, like it does for Python. See sec. 3 here for an example. It looks like there are a few options for adding this functionality. I am hoping the community might have some thoughts on the second option proposed here.


FYI, a good Julia alternative if you need one right now is Weave.jl:

Though I think the Jupyter kernal approach for Pythontex would be a good way to expand the functionality.


You can also use Jupyter/IJulia with nbconvert to output LaTeX. (For things like course notes, I usually leave documents in the form of notebooks so that students can easily run them.)


Thanks guys! Weave.jl looks really nice and I use Julia notebooks for my lectures. I’m working, however, on a textbook that is all done in latex with the tufte-book style.


Weave.jl supports latex so you can use it with tufte-book style as well. You could also use Weave.jl to implement the second option for Pythontex.

Open an issue on Weave repo if something doesn’t work as it should.


For Pythontex option 2: if you have julia file minitex.jl with the following contents:

#+ term=true
x = 1:10
y = Dict(:language => "julia")

you can call weave:

using Weave
julia> weave("minitex.jl", "tex")
INFO: Weaving chunk 1 from line 2
INFO: Report weaved to minitex.tex

And minitex.tex contains the output:

julia> x = 1:10

julia> y = Dict(:language => "julia")
Dict{Symbol,String} with 1 entry:
  :language => "julia"