Weave.jl with texminted escapes LaTeX code

Hello,

I am trying to start using Julia + LaTeX. I am familiar with R solution for integrating statistics into document typesetting with Sweave and have stumbled upon Weave.jl. For some reason, however, I am not getting an expected output while trying to execute following test document with weave:

\documentclass[a4paper]{article}
\usepackage{minted}
\usepackage{lipsum}

\title{Julia Weave}
\author{Me}

\begin{document}

Test

<<>>=
sin(2+2)
@

\begin{aligned}
    \sin(x)&=x-{\frac{x^{3}}{3!}}+{\frac {x^{5}}{5!}}-{\frac {x^{7}}{7!}}+\cdots \\[8pt]
    &=\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{(2n+1)!}}x^{2n+1}
\end{aligned}

\end{document}

The command I am using is weave("jlweave.jnw", informat="noweb", doctype="texminted"), the generated outputt however escapes all the LaTeX code, while successfully executing noweb code chunks. The tex document I am getting is:

\documentclass[12pt,a4paper]{article}

\usepackage[a4paper,text={16.5cm,25.2cm},centering]{geometry}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{bm}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{hyperref}
\usepackage{minted}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1.2ex}

\hypersetup
       {   pdfauthor = {  },
           pdftitle={  },
           colorlinks=TRUE,
           linkcolor=black,
           citecolor=blue,
           urlcolor=blue
       }

\begin{document}

{\textbackslash}documentclass[a4paper]\{article\} {\textbackslash}usepackage\{minted\} {\textbackslash}usepackage\{lipsum\}

{\textbackslash}title\{Julia Weave\} {\textbackslash}author\{Me\}

{\textbackslash}begin\{document\}

Test

\begin{minted}[texcomments = true, mathescape, fontsize=\small, xleftmargin=0.5em]{julia}
sin(2+2)
\end{minted}
\begin{minted}[texcomments = true, mathescape, fontsize=\small, xleftmargin=0.5em, frame = leftline]{text}
-0.7568024953079282
\end{minted}

{\textbackslash}begin\{aligned\}     {\textbackslash}sin(x)\&=x-\{{\textbackslash}frac\{x\^{}\{3\}\}\{3!\}\}+\{{\textbackslash}frac \{x\^{}\{5\}\}\{5!\}\}-\{{\textbackslash}frac \{x\^{}\{7\}\}\{7!\}\}+{\textbackslash}cdots {\textbackslash}[8pt]     \&={\textbackslash}sum \_\{n=0\}\^{}\{{\textbackslash}infty \}\{{\textbackslash}frac \{(-1)\^{}\{n\}\}\{(2n+1)!\}\}x\^{}\{2n+1\} {\textbackslash}end\{aligned\}

{\textbackslash}end\{document\}
\end{document}

The desired output would include the minted code block, executed by Julia, with LaTeX code unchanged.

Edit: I am using Julia v1.8.3 and Weave v0.10.9 on arm64 Mac.

Looking at the code of Weave the noweb option seems to be broken and deserted…
It just parses the document as markdown assuming different “noweb stule” delimiter for the julia code blocks.

This is an open bug: [BUG] texw example broken · Issue #412 · JunoLab/Weave.jl · GitHub

Seems that pinning Weave at 0.10.2 may be the solution until it is fixed.

1 Like

Thank you for the response!