gpoore / pythontex

A LaTeX package that executes Python and other code in LaTeX documents, and includes the output
873 stars 98 forks source link

QUESTION: how to include julia scripts #215

Open rafaelmgallego opened 1 year ago

rafaelmgallego commented 1 year ago

I am using Julia with pythontex, and I want to include a script with all the variables and functions at the beginning. I have read the Issue #27, which address the same topic for python. In the case of python I use, (I found this way before reading #27 issue)

\pyc{exec(open('myscript.py').read())}

In my case the myscript.py in the same directory as the tex file.

For Julia I have tried

\jlc{include("./myscript.jl")}

where both myscript.jl and myfile.tex are in the folder 'mydir', but pythontex looks for 'myscript.jl' in the folder 'mydir/pythontex-files-myfile' instead of 'mydir'

I want the julia script to execute, to use variables and functions in my latex document.

rafaelmgallego commented 1 year ago

I have just used

\jlc{include("../myscript.jl")}

This solves my problem (for the time being :-) )

gpoore commented 1 year ago

I believe that all of that is behaving as expected. For Python, open() is relative to working directory. For Julia, include() is relative to source file location, which will be a temp file in mydir/pythontex-files-myfile.