# Can I capture sympy output in weave document?

**URL:** <https://discourse.julialang.org/t/can-i-capture-sympy-output-in-weave-document/23633>\
**Category:** General Usage\
**Tags:** documentation\
**Created:** [April 28, 2019, 10:48pm UTC](https://discourse.julialang.org/t/can-i-capture-sympy-output-in-weave-document/23633 "2019-04-28T22:48:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cserteGT3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/csertegt3/32/8283_2.png) [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Post date:** [April 28, 2019, 10:48pm UTC](https://discourse.julialang.org/t/can-i-capture-sympy-output-in-weave-document/23633/1 "2019-04-28T22:48:46Z")

</div>

I’m interested if I can render SymPy.jl-s output with Weave just like in jupyter notebooks? I know I can weave into tex and process further, but would be easier (at least for me) if the output could directly captured in html as well.  
(For an MWE) in a notebook the following renders a nice fraction.

```julia
using SymPy
Sym(1//2)

```

Meanwhile with Weave it’s rendered as in the repl (as expected).

```julia
julia> using SymPy

julia> Sym(1//2)

```

```julia
1/2

```

I surely don’t know how jupyter/IJulia works, I just had this idea that if it’s possible to do in jupyter, it’s may be possible to do it with Weave as well. Sorry if I didn’t word my question right.

---

<div class="post-metadata">

**Author:** ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Post date:** [November 26, 2019, 1:12pm UTC](https://discourse.julialang.org/t/can-i-capture-sympy-output-in-weave-document/23633/2 "2019-11-26T13:12:03Z")

</div>

I just stumbled on a similar problem. `Sym(1//2)` works fine for me, i.e. compiled to \frac{1}/{2} but greek symbols are not converted to the latex format. I do not have a solution yet, but some thoughts:

With a jupyter notebook, it works nively due to a smart `show` function in  
[JuliaPy/SymPy.jl/src/types.jl](https://github.com/JuliaPy/SymPy.jl/blob/20d8c87f5ab9c873972e67e8d1a2b4d8fcdb354d/src/types.jl#L75)

```julia
print(sympy.pretty(x)) # gives a nice ascii line rendered by the MathJax

```

The latex version of the command seems to ignore greek variables leaving them as they are:

```julia
print(sympy.latex(α, mode="equation*"))
# outputs \begin{equation*}α\end{equation*}, not \alpha

```

Latex cannot compile them.

Any ideas on how to fix it?

---

<div class="post-metadata">

**Author:** ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Post date:** [November 26, 2019, 1:25pm UTC](https://discourse.julialang.org/t/can-i-capture-sympy-output-in-weave-document/23633/3 "2019-11-26T13:25:35Z")

</div>

kind of a bug

```julia
using SymPy
@vars α
[α α] # 1)
[α; α] # 2)
(α, α) # 3)

```

The `weave2pdf` would produce:

```nohighlight
# 1) does not compile
\[\left[\begin{array}{rr}α&α\end{array}\right]\] 
# 2) does not compile
\[\left[ \begin{array}{r}α\\α\end{array} \right] \]
# 3) compiles
\begin{lstlisting}
((*@\ensuremath{\alpha}@*), (*@\ensuremath{\alpha}@*))
\end{lstlisting}

```
