3

I have been trying to strikeout a colored text defined by a macro, but it seems that it does not support line breaking. I have a command bt to type blue text and I want to strike some of the text with a red stroke (command rs). Following is a MCVE of my problem.

\documentclass{article}
\usepackage{ulem,xcolor}

\newcommand{\bt}[1]{\textcolor{blue}{#1}} % bt: blue text
\newcommand{\rt}[1]{\textcolor{red}{#1}}  % rt: red text
\newcommand{\rs}[1]{\rt{\sout{#1}}}       % rs: red stroke

\textwidth=12cm % Forcing linebreak at 12cm

\usepackage[T1]{fontenc}
\begin{document}
    \bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}

    \rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}

    \rs{\bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}}     
\end{document}

This code produces the following output. It does strike out the text with a red stroke, however, this destroys the line breaking of my paragraph. example

I have also tried the soul package and using the expandafter trick (from this link), but it did not work for me.

1 Answers1

3

With soul there are no problems.

\documentclass{article}
\usepackage{soul,xcolor}

\newcommand{\bt}[1]{\textcolor{blue}{#1}} % bt: blue text
\newcommand{\rt}[1]{\textcolor{red}{#1}} % rt: red text
\newcommand{\rs}[1]{\setstcolor{red}\st{#1}}       % rs: red stroke

\textwidth=12cm % Forcing linebreak at 12cm

\usepackage[T1]{fontenc}
\begin{document}
    \bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}

    \rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}

    \textcolor{blue}{\rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
            sodales massa ac dapibus dignissim. Phasellus ac pretium urna. 
            Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis 
            tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}}     
\end{document}

enter image description here

  • It is working when I type \bt{\rs{text}} on this order. Is there anyway that I can make it work on the other way around (\rs{\bt{}})? The idea is that a writer X will make contributions using his color and then some writer Y might strike out some of X's text. Thus I think it would make more sense to use \rs\bt, but if it can't be done, I will accept your answer after a few days. – Alexandre H T Dias Mar 18 '19 at 16:46