Please, what I need is an example environment that has a violet [rgb(238, 130, 238) for example] background, the font color black and this has to work on xelatex (I need this compiler because I'm working with Japanese texts and furigana that only works on xelatex)

Use this sentence on your example: \usepackage{mathptmx} \begin{document} \begin{example} {\fontsize{25}{30}\selectfont 口} meaning mouth Kun'yomi: くち\ On'yomi: コウ、ク\ \end{example} \end{document}

  • As of 2020, the font will also work in LuaLaTeX, which has fewer color bugs.
    – Davislor
    Commented Dec 24, 2020 at 23:21

2 Answers 2


you can e.g. use tcolorbox. It will works with xelatex too:

\definecolor{myviolett}{RGB}{238, 130, 238}
some text

enter image description here

  • Thank you, for this comment, especially for this quick answer at this time of the year. This will work, but I expecting something more sophisticated for a book example, like @Jonathan Komar's answer on tex.stackexchange.com/questions/21227/example-environment ... but the package "mdframed" always results in an error on xelatex. I'll use this in my article's texts now! Thank you, hombre!
    – amuniz1
    Commented Dec 24, 2020 at 23:50
  • @Alex990MW Ulrike is a mujer. :)
    – Davislor
    Commented Dec 25, 2020 at 0:00
  • Sorry, perdão, gomenasai! @Ulrike Fischer
    – amuniz1
    Commented Dec 25, 2020 at 0:05
  • You only asked about violett background and black text, if you want something more sophisticated you should be more specific. Beside this: everything that you can do with mdframed is also possible with tcolorbox (and more, as it is a much more powerful package). Commented Dec 25, 2020 at 11:27

The following works in either LuaLaTeX or XeLaTeX:

\tracinglostchars=2 % Warn if a character is missing
\usepackage{iftex} % For \ifluatex, \ifxetex
\usepackage{unicode-math} % For \setmathfont
\usepackage{xcolor, framed} % For shaded*

\defaultfontfeatures{ Scale=MatchLowercase,
                      Ligatures=TeX }

          [Ligatures=Common,Scale=1.0,Language=Default]{TeX Gyre Termes} % Clone of Times.
          [Ligatures=Common,Language=Default]{TeX Gyre Heros} % Clone of Helvetica.
          [Language=Default]{Libertinus Mono}
\setmathfont{TeX Gyre Termes Math}

  \babelprovide[import, onchar=ids fonts]{japanese}

% Define \babelfont[japanese]{tt} here, if needed.

\definecolor{shadecolor}{RGB}{238, 130, 238}

{\huge 口} meaning mouth Kun'yomi: くち\ On'yomi: コウ、ク\ 

Termes/Hirano Aji Mincho sample

Here, I used the framed package, which should be able to deal with page breaks. Ulrike Fischer’s solution based on tcolorbox will also work, and you can configure that package to do fancier things.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .