[Tex/LaTex] Strike through with colors

beamerstrikeout

My question is related to: Strikeout in different color appears behind letters, not on top of them, except that I use beamer instead of article. Therefore, the solution provided there is somehow not working. The example I have at hand is:

\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
\documentclass[t, 10 pt, mathserif]{beamer}
\usepackage{xparse,soul}

\makeatletter
\NewDocumentCommand{\sotwo}{O{red}O{black}+m}
    {%
        \begingroup
        \setulcolor{#1}%
        \setul{-.5ex}{.4pt}%
        \def\SOUL@uleverysyllable{%
            \rlap{%
                \color{#2}\the\SOUL@syllable
                \SOUL@setkern\SOUL@charkern}%
            \SOUL@ulunderline{%
                \phantom{\the\SOUL@syllable}}%
        }%
        \ul{#3}%
        \endgroup
    }
\makeatother

\begin{document}
Hello \sotwo{Welt} World!

\sotwo[green]{Here is a long sentence that will span across a number of lines to force a linebreak}

\sotwo[green][blue]{Here is a long sentence that will span across a number of lines to force a linebreak}

Here is a long sentence that will span across a number of lines to force a linebreak

\end{document} 

Any ideas will be greatly appreciated! Thanks!

Best Answer

A simple change to the code works in this case: replace \setulcolor{#1}% by simply \color{#1}% in the definition of \sotwo.

Sample output

\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
\documentclass[t, 10pt]{beamer}

\usepackage{xparse,soul}

\makeatletter
\NewDocumentCommand{\sotwo}{O{red}O{black}+m}
    {%
        \begingroup
        \color{#1}%
        \setul{-.5ex}{.4pt}%
        \def\SOUL@uleverysyllable{%
            \rlap{%
                \color{#2}\the\SOUL@syllable
                \SOUL@setkern\SOUL@charkern}%
            \SOUL@ulunderline{%
                \phantom{\the\SOUL@syllable}}%
        }%
        \ul{#3}%
        \endgroup
    }
\makeatother

\begin{document}

Hello \sotwo{Welt} World!

\sotwo[green]{Here is a long sentence that will span across a number
of lines to force a linebreak}

\sotwo[green][blue]{Here is a long sentence that will span across a
number of lines to force a linebreak}

Here is a long sentence that will span across a number of lines to
force a linebreak

\end{document}