5

In analogy to pythontex, what would it take to create juliatex?

  • 1
    pythontex exists. What I'm asking is what would have to be done to create a LaTeX extension that would have the same functionality as pythontex but uses julia instead of python. – JPi Jun 23 '17 at 0:43
  • 6
    According to the pythontex documentation, it has already been done, so the answer to the question is "it takes nothing". – alephzero Jun 23 '17 at 0:46
  • 1
    I've removed it..... – JPi Jun 23 '17 at 1:05
  • 1
    @alephzero It seems like that should be turned into an answer. – Alan Munn Jun 23 '17 at 1:13
  • 1
    @alephzero I'd accept your comment as an answer, though I'd appreciate a short example. – JPi Jun 23 '17 at 1:19
5

(If alephzero posts an answer, I'll accept his/hers)

But here goes:

\documentclass{article}


\usepackage{fontspec}
\usepackage[usefamily=julia]{pythontex}

\begin{document}

    \begin{juliacode}
        using LaTeXStrings
        println(L"y=x'\beta+u")
    \end{juliacode}


\end{document}

Compile using lualatex, then pythontex, then lualatex. Ha!

enter image description here

EDIT

A second, somewhat more sophisticated example:

\documentclass{article}


\usepackage{fontspec}
\usepackage[usefamily=julia]{pythontex}

\begin{document}

    \begin{juliacode}
        srand(1)
        n=100
        X=[ones(n) randn(n)]
        y=X* [1.0;2.0] +randn(n)*3.0
        b=X\y
        println("OLS regression coefficients=",round(b,2))
    \end{juliacode}


\end{document}

enter image description here

  • Can you please show us something concise, but more useful, julia could do for us? – marsupilam Jun 23 '17 at 12:12
  • Will try to put something in later. – JPi Jun 23 '17 at 15:04
  • @marsupilam done – JPi Jun 23 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.