3

I would like to suppress text that has been strickenthrough (struckthrough?). I don't think that hide does this, because hide replaces with an empty box of the same size.

I think something like \renewcommand\st that replaces whatever each instance of \st{ }\ with nothing would work well, but I cannot figure out how to do this (nor I have a found another post that quite does this).

Minimum working example:

\documentclass[12pt]{article}
\usepackage{soul}
\begin{document}

This text should remain visible 
\st{but the strikethrough text should just disappear} 
so that thus just flows from the word visible before the strikethrough.

\end{document}
5
  • 2
    Perhaps \renewcommand\st[1]{\unskip}, after loading the soul package. The \unskip prevents the fore and aft spaces from showing up as two separate space tokens. Feb 11, 2020 at 17:22
  • Welcome to TeX.SX! You mean that you would like a command that makes its argument to be simply ignored?
    – Vincent
    Feb 11, 2020 at 17:25
  • Works like a charm! Thank you.
    – C Sev
    Feb 11, 2020 at 17:26
  • @Vincent that is precisely it. The suggestions above annuls the command and then removes and extra space issues.
    – C Sev
    Feb 11, 2020 at 17:29
  • @StevenB.Segletes perhaps better would be \renewcommand\st[1]{\ifhmode\unskip\fi}.
    – Skillmon
    Feb 11, 2020 at 18:07

1 Answer 1

2

One solution would be to use \unskip like suggested by @StevenB.Segletes. But instead I'd prefer to use \@bsphack\@esphack, as \unskip would gobble a space before \st, even if there is no space following it (the following illustrates this).

Additionally I'd use \ifhmode for the \unskip solution, as you'd typically not want to remove any vertical space, and the \@bpshack\@esphack solution doesn't need it, as \@bsphack and \@esphack both test \ifhmode themselves.

What I'd use:

\documentclass[]{article}

\usepackage{soul}

\makeatletter
\renewcommand\st[1]{\@bsphack\@esphack}%
\makeatother

\begin{document}
This text should remain visible.
\st{but the strikethrough text should just disappear} 
So that thus just flows from the word visible before the strikethrough.
\end{document}

Example comparing both solutions:

\documentclass[]{article}

\usepackage{soul}

\begin{document}
This text should remain visible.
\st{but the strikethrough text should just disappear} 
So that thus just flows from the word visible before the strikethrough.

\renewcommand\st[1]{\ifhmode\unskip\fi}%
This text should remain visible.
\st{but the strikethrough text should just disappear} 
So that thus just flows from the word visible before the strikethrough.

\noindent
\makebox[\linewidth][s]
  {%
    This text should remain visible.
    \st{but the strikethrough text should just disappear}%
    So that thus%
  }

\makeatletter
\renewcommand\st[1]{\@bsphack\@esphack}%
\makeatother
\noindent
\makebox[\linewidth][s]
  {%
    This text should remain visible.
    \st{but the strikethrough text should just disappear}%
    So that thus%
  }

This text should remain visible.
\st{but the strikethrough text should just disappear} 
So that thus just flows from the word visible before the strikethrough.
\end{document}

enter image description here

2
  • In the example, this solution works great. When I put it into my working document, though, it prints the phrase "bsphackesphack" everywhere where I've used \st. Do \@bsphack and \@esphack collide with other packages? (Incidentally, I experimented with placing the renewcommand line at different places, including after the last package call).
    – C Sev
    Feb 11, 2020 at 18:25
  • @CSev you need to use \makeatletter before and \makeatother after the \renewcommand, otherwise you can't access macros that have a @ in their name and try to use \@ instead (in this case), which does something completely different. As you might know, TeX only allows for letters in control sequence names, \makeatletter changes the category of @ to be considered a letter.
    – Skillmon
    Feb 11, 2020 at 18:35

You must log in to answer this question.

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