Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It can not be concatenated with other strings #56

Closed
Leon6j opened this issue Nov 5, 2021 · 1 comment
Closed

It can not be concatenated with other strings #56

Leon6j opened this issue Nov 5, 2021 · 1 comment

Comments

@Leon6j
Copy link

Leon6j commented Nov 5, 2021

My goal is to have my special character concatenated with some other strings, so that they can be used as the xlabel or ylabel of my plot. Here is an example: "Dissolved oxygen (μmol/kg)". Unfortunately, I'm unable to do that. Below are what I've tried so far:

a = L"\mu"
𝜇

b = "mol"
“mol”

C1 = join(a,b)
“$mol\molmmolumol$”

C2 = string(a,b)
“$\mu$mol”

C3 = a * b
“$\mu$mol”

C4 = [a b]
1×2 Matrix{AbstractString}:
L"$\mu$" "mol"

C5 = hcat(a,b)
1×2 Matrix{AbstractString}:
L"$\mu$" "mol"

@stevengj
Copy link
Member

stevengj commented Nov 6, 2021

Closing as a duplicate of #17.

a * b works fine — it is just producing an ordinary string, which should still produce an equation in your plot label even though it doesn't display as rendered math in a notebook. You can also do LaTeXString(a * b) if you want it to render in the notebook.

(There is a common misconception that LaTeXString does some LaTeX rendering itself — it is mainly just a convenient way to type a LaTeX equation as a string without adding lots of extra backslashes. An ordinary String can also be used to pass math labels to plots.)

@stevengj stevengj closed this as completed Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants