swift - How can I set background color of text with LaTeXSwiftUI? - Stack Overflow

admin2025-04-18  2

I am using the LateXSwiftUI package. I want to set the background color of part of the text. However, using \colorbox does not seem to set the background to the desired color of red, resulting in a black box being put over "Hello." I have tried other colors, RGB colors, and hex colors, none of which have helped.

Code:

LaTeX("\\colorbox{red}{Hello}, World!")
.parsingMode(.all)

I am using the LateXSwiftUI package. I want to set the background color of part of the text. However, using \colorbox does not seem to set the background to the desired color of red, resulting in a black box being put over "Hello." I have tried other colors, RGB colors, and hex colors, none of which have helped.

Code:

LaTeX("\\colorbox{red}{Hello}, World!")
.parsingMode(.all)

Share asked Jan 30 at 6:07 Churro the DuckChurro the Duck 1511 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

try this:

LaTeX("\\colorbox{red}{Hello}, World!")
    .imageRenderingMode(.original)  // <--- here
    .parsingMode(.all)
转载请注明原文地址:http://anycun.com/QandA/1744935447a89710.html