# Creating symbols from strings in Symbolics package

**URL:** https://discourse.julialang.org/t/creating-symbols-from-strings-in-symbolics-package/99071
**Category:** New to Julia
**Created:** [May 18, 2023, 3:39pm UTC](https://discourse.julialang.org/t/creating-symbols-from-strings-in-symbolics-package/99071 "2023-05-18T15:39:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![brombo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brombo/32/47867_2.png) [@brombo](https://discourse.julialang.org/u/brombo)
#### Post date: [May 18, 2023, 3:39pm UTC](https://discourse.julialang.org/t/creating-symbols-from-strings-in-symbolics-package/99071/1 "2023-05-18T15:39:18Z")

</div>

Firstly I am talking about `Num` and `Real` symbols in the Julia `Symbols` package. If I am talking about coding symbols in general I know I can create then from a string by

```julia
X2 = Symbol("x^2")
println(X2)
x^2

```

but in the `Symbolics` package you create a symbolic symbol with `@variables X2::Num` or `@variables X2::Real`. Is there anyway to create a symbolic symbol from a text string to get the same printing behavior as demonstrated above. For example I would like a symbolic symbol `g12` to print as `\bs{e}_1\cdot\bs{e}_2` so when I print `g12` using a latex print function I get \boldsymbol{e}\_1\cdot\boldsymbol{e}\_2.

---

<div class="post-metadata">

### Author: ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)
#### Post date: [May 18, 2023, 4:51pm UTC](https://discourse.julialang.org/t/creating-symbols-from-strings-in-symbolics-package/99071/2 "2023-05-18T16:51:06Z")

</div>

```julia
julia> using Symbolics

julia> x = Symbol("x") # Create a symbol from a string
:x                       
                         
julia> x, = @variables $x # interpolate the symbol into a variable expression to create a Symbolics variable
1-element Vector{Num}:   
 x                       
                         
julia> expr = x^2 # A symbolic expression    
x^2                      

julia> using Latexify
                         
julia> latexify(expr)    
L"\begin{equation}       
x^{2}                    
\end{equation}           
"                        
                         

```

---

<div class="post-metadata">

### Author: ![brombo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brombo/32/47867_2.png) [@brombo](https://discourse.julialang.org/u/brombo)
#### Post date: [May 18, 2023, 8:50pm UTC](https://discourse.julialang.org/t/creating-symbols-from-strings-in-symbolics-package/99071/3 "2023-05-18T20:50:58Z")

</div>

Thank you, thank you, thank you! I have been doing python coding for over 25 years and started Julia last week. It will take a while to get used to the new paradigm. Now I will proselytize some graphics software with an interface for Julia -

[https://asymptote.sourceforge.io/](https://asymptote.sourceforge.io/)

[https://github.com/sswatson/AsyPlots.jl](https://github.com/sswatson/AsyPlots.jl)
