# Indexing within double quotation mark

**URL:** <https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968>\
**Category:** General Usage\
**Created:** [January 4, 2020, 5:15pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968 "2020-01-04T17:15:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [January 4, 2020, 5:15pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/1 "2020-01-04T17:15:02Z")

</div>

Hi community,  
Julia is amazing in “$a”. One step further, are there any way to achieve this?

> plot(…,label=[“a1 is $a[:,1], a2 is $a[:,2].”])

Or other command like ‘legend!(a,b)’ to define which parameters will be specified in legend?

---

<div class="post-metadata">

**Author:** ![zaki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zaki/32/10300_2.png) [@zaki](https://discourse.julialang.org/u/zaki)\
**Post date:** [January 4, 2020, 5:59pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/2 "2020-01-04T17:59:33Z")

</div>

It could be done by enclosing the expression with parentheses, e.g. `"a1 is $(a[:,1])"`.

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [January 4, 2020, 6:43pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/3 "2020-01-04T18:43:13Z")

</div>

Thank you. It works.  
`plot(c,label=["a1= $(a[:,1])" , " a2=$(a[:,2])"])`

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [January 4, 2020, 11:34pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/4 "2020-01-04T23:34:53Z")

</div>

An extra addition for getting \>=1 parameters presented for each series in legend.  
As `"$(a[1,2])"` cannot function with a commas betwen parameters included like `"a1=$(a[1,2]), a2=$(a[2,2])"` , `""" """` would nail it, which is:

` scatter(a,simu_mtx[a,:], label=["""s0=$(b[1,1])", "2Nμ=$(b[1,2])""" , """s0=$(b[2,1])", "2Nμ=$(b[2,2])"""])`

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [January 5, 2020, 11:28pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/5 "2020-01-05T23:28:54Z")

</div>

One following question:  
Compared to specify the legend by listing, I tried to use for loop.

```julia
legend=String[]
for i in 1:2, j in 1:2
  push!(legend,"""s0=$(ndx_mtx[j,i])", "2Nμ=$(ndx_mtx[j,i])""")
end
println(legend)

#on REPL print
["s0=0.05 \",\"2Nμ=0.05 ", "s0=1.0 \",\"2Nμ=1.0 ", "s0=0.005 \",\"2Nμ=0.005 ", "s0=1.0 \",\"2Nμ=1.0 "]

```

The `\` in printed output is unwanted. Is there a way to leave it while keeping `"s0=0.05 \",\"2Nμ=0.05 "` as one element pushed to legend string vector?

---

<div class="post-metadata">

**Author:** ![zaki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zaki/32/10300_2.png) [@zaki](https://discourse.julialang.org/u/zaki)\
**Post date:** [January 5, 2020, 11:55pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/6 "2020-01-05T23:55:27Z")

</div>

The `\` is an escape character for the single quotes. Try adding a dot after the println command, i.e. `println.(legend)`, and you should see that there are single quotes without backslashes.

It wasn’t clear to my why triple quotes (`"""`) were being used. I think that the line in the loop could be:

```julia
push!(legend,"s0=$(ndx_mtx[j,i]), 2Nμ=$(ndx_mtx[j,i])")

```

and that should work.

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [January 6, 2020, 12:16am UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/7 "2020-01-06T00:16:09Z")

</div>

It works now 🙂 Thank you.

---

<div class="post-metadata">

**Author:** ![Alex\_Manners](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex_manners/32/49308_2.png) [@Alex\_Manners](https://discourse.julialang.org/u/Alex_Manners)\
**Post date:** [October 6, 2023, 1:35pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/8 "2023-10-06T13:35:21Z")

</div>

The program demands a to be defined

---

<div class="post-metadata">

**Author:** ![Alex\_Manners](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex_manners/32/49308_2.png) [@Alex\_Manners](https://discourse.julialang.org/u/Alex_Manners)\
**Post date:** [October 9, 2023, 6:33pm UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/9 "2023-10-09T18:33:46Z")

</div>

I would like tu know how I could introduce Latex symbols inside the label section while indexing.

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [October 10, 2023, 6:12am UTC](https://discourse.julialang.org/t/indexing-within-double-quotation-mark/32968/10 "2023-10-10T06:12:09Z")

</div>

Hi @Alex_Manners and welcome to the forum 🙂

Please consider opening a new topic – it makes it easier to find and answer your question.

But on the topic: You could try to type the characters directly, e.g. in the way described here:  
[https://docs.julialang.org/en/v1/manual/unicode-input/](https://docs.julialang.org/en/v1/manual/unicode-input/)

Or have a look at this package if you need full LaTeX support:

> **[GitHub - JuliaStrings/LaTeXStrings.jl: convenient input and display of LaTeX...](https://github.com/JuliaStrings/LaTeXStrings.jl)**
>
> convenient input and display of LaTeX equation strings for the Julia language - GitHub - JuliaStrings/LaTeXStrings.jl: convenient input and display of LaTeX equation strings for the Julia language
