2

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!

2

2 Answers 2

3

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} 
0
0

You can also apply the patch from Why is it that coloring in soul in beamer is not visible:

\makeatletter
\newcommand\SoulColor{%
  \let\set@color\beamerorig@set@color
  \let\reset@color\beamerorig@reset@color}
\makeatother
\SoulColor

which yields:

enter image description here

Code:

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

% https://tex.stackexchange.com/questions/41683/why-is-it-that-coloring-in-soul-in-beamer-is-not-visible
\makeatletter
\newcommand\SoulColor{%
  \let\set@color\beamerorig@set@color
  \let\reset@color\beamerorig@reset@color}
\SoulColor

\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}

You must log in to answer this question.

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