ho-tex / soul

LaTeX package "soul" for letterspacing, underlining, striking out and other evil things
LaTeX Project Public License v1.3c
4 stars 1 forks source link

Can't use mixed colors #2

Closed kpym closed 1 year ago

kpym commented 3 years ago

For some reason I can't use directly colors like yellow!35!white. The following code works

\colorlet{hl}{yellow!35!white}
\sethlcolor{hl}

but the following one don't

\sethlcolor{yellow!35!white}

It looks like that soul(utf8) use under the hood \textcolor which is ok with mixed colors. So I can't get it why it is not working.

u-fischer commented 3 years ago

Please show a small but complete example. That makes it much easier to test the issue.

kpym commented 3 years ago

@u-fischer Here is an example of MWE (the results are identical with pdflatex and with xelatex).

\documentclass{article}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[utf8]{inputenc}
\else
  \usepackage{fontspec}
\fi
% --------------------------
\usepackage{xcolor}
\colorlet{hl}{red!35!white}
% --------------------------
\usepackage{soulutf8}
% --------------------------
\begin{document}
  \sethlcolor{hl}
  \hl{Test using \texttt{hl} color}

  \sethlcolor{red!35!white}
  \hl{Test using \texttt{red!35!white} color}
\end{document}

image

kpym commented 3 years ago

@u-fischer This behavior is not specific to soulutf8 because we can see the same thing with the original soul package.

\documentclass{article}
% --------------------------
\usepackage{xcolor}
\colorlet{hl}{blue!35!white}
% --------------------------
\usepackage{soul}
% --------------------------
\begin{document}
  \sethlcolor{hl}
  \hl{Test using \texttt{hl} color}

  \sethlcolor{blue!35!white}
  \hl{Test using \texttt{blue!35!white} color}
\end{document}

image

davidcarlisle commented 3 years ago

a quick workaround would seem to be

\documentclass{article}
% --------------------------
\usepackage{xcolor}
\colorlet{hl}{blue!35!white}
% --------------------------
\usepackage{soul}
\let\zz\sethlcolor
\def\sethlcolor#1{\colorlet{soul-#1}{#1}\zz{soul-#1}}
% --------------------------
\begin{document}
  \sethlcolor{hl}
  \hl{Test using \texttt{hl} color}

  \sethlcolor{blue!35!white}
  \hl{Test using \texttt{blue!35!white} color}
\end{document}

image

kpym commented 3 years ago

@davidcarlisle We can even do a more dirty thing: \def\sethlcolor#1{\colorlet{#1}{#1}\zz{#1}} ;)

kpym commented 3 years ago

What I do not understand is that in the code it looks like \sethlcolor use the color only through \textcolor{#1} which should be ok... but probably I miss something.

u-fischer commented 3 years ago

@kpym It is a known incompability between soul and xcolor, see https://tex.stackexchange.com/a/520315/2388

We will look for a real fix.

kpym commented 3 years ago

@u-fischer Tanks for considering my request and to pointing me to the TeX.SX topic.

u-fischer commented 1 year ago

This has been resolved with version 3.0.