我想隐藏已删除的文本。我认为这不会hide
产生效果,因为hide
它会用相同大小的空框替换。
我认为类似这样的用无\renewcommand\st
替换每个实例的方法\st{ }\
会很好用,但我不知道如何做到这一点(我也没有找到另一篇完全做到这一点的帖子)。
最小工作示例:
\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}
答案1
一个解决方案是使用\unskip
像建议的那样@StevenB.Segletes。但我更喜欢使用\@bsphack\@esphack
,因为这样\unskip
会吞掉前面的空格\st
,即使后面没有空格(下面说明了这一点)。
此外,我会使用\ifhmode
它作为\unskip
解决方案,因为您通常不想删除任何垂直空间,并且\@bpshack\@esphack
解决方案不需要它,因为两者\@bsphack
都可以自行\@esphack
测试\ifhmode
。
我会用什么:
\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}
比较两种解决方案的示例:
\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}