Ask Your Question
0

How do you assign (different) LaTex names to elements of a list?

asked 2021-06-16 21:52:17 +0200

sum8tion gravatar image

Say I have the following list of variables.

v = {(i,j): var("v_{}{}".format(i, j), latex_name="v_{{}{}}") for i in range(2) for j in range(2)}

How do I make it so that when I use the

show(v[0,0])

command, I get $v_{0,0}$ as output? I've tried stuff like

v = {(i,j): var("v_{}{}".format(i, j), latex_name="v_{i,j}") for i in range(2) for j in range(2)}

and

v = {(i,j): var("v_{}{}".format(i, j), latex_name="v_{{i}{j}}") for i in range(2) for j in range(2)}

but it only ever give me stuff like $v_{i,j}$ where it's just the literal symbols $i$ and $j$, not the entries of

v[k,m]

for some $k$ and $m$ I plug in, like 0, 0.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-16 22:10:12 +0200

tmonteil gravatar image

updated 2021-06-16 22:13:49 +0200

You sould use double the braces as follows:

v = {(i,j): var("v_{}{}".format(i, j), latex_name="v_{{{}{}}}".format(i, j)) for i in range(2) for j in range(2)}
edit flag offensive delete link more

Comments

Thank you!

sum8tion gravatar imagesum8tion ( 2021-06-16 22:22:47 +0200 )edit

I have a bit of a follow-up, lets say I want the latex name to have a bar over it for conjugation, like $\bar{v}$. My naive guess of

v = {(i,j): var("v_{}{}".format(i, j), latex_name="\bar{v}_{{{}{}}}".format(i, j)) for i in range(2) for j in range(2)}

doesn't seem to work. Any suggestions?

sum8tion gravatar imagesum8tion ( 2021-06-17 05:27:03 +0200 )edit

Idem, use double braces around v.

tmonteil gravatar imagetmonteil ( 2021-06-17 09:02:03 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-06-16 21:52:17 +0200

Seen: 47 times

Last updated: Jun 16