How can I change text color in nested texts?

Hi,

I have a stack of 3 rectangles, and a text in each rectangle. The code is as follows:
#stack(
dir: ttb,
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[first] rectangle with random text.]
],
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[second] rectangle with random text.]
],
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[third] rectangle with random text.]
],
)

I am trying to change the color of the nested text (e.g text(size: 12pt)[This is the text(red)[first] rectangle with random text.]). Typst does not recognize the inner text and print text(red)[first]
with no color applied.

Thank you.

I have fixed the problem. The solution is as follows:
#stack(
dir: ttb,
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[first] rectangle with random text.]
],
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[second] rectangle with random text.]
],
rect(width: 200pt, height: 80pt)[
text(size: 12pt)[This is the text(red)[third] rectangle with random text.]
],
)

Hi @Andrew_Duncan, please familiarize yourself with the question guidelines, particularly the part about formatting code:

As you can see the code in your post is not readable and would not have encouraged our helpful community to engage with your issue.

I will move this post to Questions for you, but I expect you to

1 Like