# Trying to use textbook with ChemEquations.jl package

**URL:** <https://discourse.julialang.org/t/trying-to-use-textbook-with-chemequations-jl-package/55356>\
**Category:** Chemistry\
**Created:** [February 15, 2021, 10:27pm UTC](https://discourse.julialang.org/t/trying-to-use-textbook-with-chemequations-jl-package/55356 "2021-02-15T22:27:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![22natarajank](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/22natarajank/32/20691_2.png) [@22natarajank](https://discourse.julialang.org/u/22natarajank)\
**Post date:** [February 15, 2021, 10:27pm UTC](https://discourse.julialang.org/t/trying-to-use-textbook-with-chemequations-jl-package/55356/1 "2021-02-15T22:27:23Z")

</div>

I have been learning Julia along side my AP chemistry class and was trying the ChemEquations.jl. It uses keyword ce to define a chemical Equations like this.

balance(ce"Al{3} + Cl{-1} = AlCl3")

What is ce above as a language construct? If I want someone to enter the equation in a text box it will be a string. If I define the equation as a string, how do I trigger the ce to convert?  
eq=“Al{3} + Cl{-1} = AlCl3”

Here is my GitHub repository link so you can check equation notebook out if you would like!

> **[Highschool-Julia/chemistry at main · 22natarajank/Highschool-Julia](https://github.com/22natarajank/Highschool-Julia/tree/main/chemistry)**
>
> main/chemistry

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [February 17, 2021, 12:08pm UTC](https://discourse.julialang.org/t/trying-to-use-textbook-with-chemequations-jl-package/55356/2 "2021-02-17T12:08:26Z")

</div>

I don’t know ChemEquations specifically (you might try posting an issue in that package), but in general see:

- [Metaprogramming · The Julia Language](https://docs.julialang.org/en/v1/manual/metaprogramming/#Non-Standard-String-Literals)
- [Strings · The Julia Language](https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals)

---

<div class="post-metadata">

**Author:** ![derikk](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@derikk](https://discourse.julialang.org/u/derikk)\
**Post date:** [February 17, 2021, 2:07pm UTC](https://discourse.julialang.org/t/trying-to-use-textbook-with-chemequations-jl-package/55356/3 "2021-02-17T14:07:19Z")

</div>

This is a [string macro](https://sodocumentation.net/julia-lang/topic/5817/string-macros). You can construct it using the `ce_str` macro, which it parses to:

```julia
equation = @ce_str "C3H8 + O2 = CO2 + H2O"
balance(equation)

```

As far as I know, you can’t pass the value of a variable to a macro the same way as a string literal. But for your purposes, you can use the `ChemEquation(str)` method:

```julia
equation_string = "C3H8 + O2 = CO2 + H2O"
equation = ChemEquation(equation_string)
balance(equation)

```
