3

This is related to Vary transparency of colorbox in a sentence

I would like to have a transparent colorbox for some overlay and this attempt is not working

\documentclass{article}

\usepackage{soul,xcolor} \usepackage{transparent} \sethlcolor{red} \begin{document}

\hl{This is}% \transparent{0.1}{\hl{\hspace{5cm}}}%

\end{document}

AndréC
  • 24,137

1 Answers1

1

I point out that

\hl{\hspace{5cm}}}

produces an error, regardless of the use of transparency. However, one can use a \rule to achieve a blank field and with the added use of \transparent, that colored rule field can become transparent.

After some confusion on my part seemingly related to multiple compilations required for the transparent package, it seems to work.

Take this MWE:

\documentclass{article}

\usepackage{soul,xcolor} \usepackage{transparent} \sethlcolor{red} \begin{document}

\leavevmode \rlap{hi mom how are you?}% \transparent{.6}{\hl{xyz}\color{yellow}\rule{1in}{2ex}} \end{document}

I get something that looks like I would expect.

enter image description here

If I change the \transparent parameter to .1 and perform the requisite numbers of compilations, the result changes to

enter image description here

which also follows what the package is apparently supposed to do. As the transparency approaches unity, the red and yellow fields become opaque.