# How to convert \`x\[1\] = 1.0\` as $x\_1$ = 1.0 in Jupyter notebook?

**URL:** <https://discourse.julialang.org/t/how-to-convert-x-1-1-0-as-x-1-1-0-in-jupyter-notebook/91025>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [November 30, 2022, 2:22am UTC](https://discourse.julialang.org/t/how-to-convert-x-1-1-0-as-x-1-1-0-in-jupyter-notebook/91025 "2022-11-30T02:22:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pppoe5](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Post date:** [November 30, 2022, 2:22am UTC](https://discourse.julialang.org/t/how-to-convert-x-1-1-0-as-x-1-1-0-in-jupyter-notebook/91025/1 "2022-11-30T02:22:05Z")

</div>

MWE:

```julia
using JuMP, GLPK
model = Model(GLPK.Optimizer)
@variable(model, x[i=1:4]>= 0.5, Int)
@objective(model, Min, sum(x))
optimize!(model)

for x in all_variables(model)
    println("$(name(x)) = $(value(x))")
end

```

As you know, run it in `Jupyter notebook`, you can get the output like this:

```julia
x[1] = 1.0
x[2] = 1.0
x[3] = 1.0
x[4] = 1.0

```

and when you just input `x[1]`, you will get： x\_1

So, I want to show my output like:

x\_1 = 1.0\\ x\_2 = 1.0\\ x\_3 = 1.0\\ x\_4 = 1.0

How to get these result with a simple code? And it will be the best if this result can be showed in REPL.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 30, 2022, 2:50am UTC](https://discourse.julialang.org/t/how-to-convert-x-1-1-0-as-x-1-1-0-in-jupyter-notebook/91025/2 "2022-11-30T02:50:40Z")

</div>

There’s no easy answer to this. JuMP has a special `show` call to print variables and constraints in LaTeX, and this doesn’t get called for things via `println`.

What do you need if for? What’s your goal?

You could do something like this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/6/561e35d284e9f6dc5631583a8d07c21b309813ac.png)

or, using the [LaTeXStrings.jl](https://github.com/stevengj/LaTeXStrings.jl) package:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/9/b9d8e11ee30c2816c1a62b057cae43280df186bc.png)

---

<div class="post-metadata">

**Author:** ![pppoe5](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Post date:** [November 30, 2022, 3:07am UTC](https://discourse.julialang.org/t/how-to-convert-x-1-1-0-as-x-1-1-0-in-jupyter-notebook/91025/3 "2022-11-30T03:07:40Z")

</div>

I just think the result show in LaTeX style is more friendly which make variables look like letters printed in real books.
