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.

2 Likes

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

https://github.com/mpastell/Weave.jl

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

1 Like

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:

\begin{juliaterm}
julia> x = 1:10
1:10

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

\end{juliaterm}
2 Likes

Is there a way in principle to flag figures in the original markdown doc so that they appear as margin figures in the tufte-book?

I suppose I could do this with regex. But wonder if there’s some standard method for applying rules like this.

Also, any straight forward way to includetex the Tex output of plots.jl using PGFplotsX backend, without manually doing it in LaTeX?