划掉与相邻单词重叠的单词

划掉与相邻单词重叠的单词

我已经想出了如何添加交叉词tcolorbox

\documentclass{article}\usepackage{xcolor} \usepackage[most]{tcolorbox}

\begin{document}

Of course, presenting this solution would be cheating. And, no, it won't work in all cases, due to strict limitations on the pairs 
\tcbox[tcbox raise base,
breakable,nobeforeafter, enhanced jigsaw, opacityback=0, sharp corners, parbox=false, boxrule=0pt, top=0pt,bottom=0pt,left=0pt,right=0pt, boxsep=0pt, frame hidden, parbox=false, 
  finish={\draw[thick,red] (frame.south west)--(frame.north east);\draw[thick,red] (frame.south east)--(frame.north west);}]{
  accepted
  }
  by \textbackslash{}line. Your professor surely knows that TeX doesn't draw oblique lines. With the standard package pict2e it's easier and it will work in any case.

\end{document}

在此处输入图片描述

我在这里划掉了单词 accept。但是,我希望这个划线能稍微延伸一点,比如说 1 厘米,请看我的插图。

在此处输入图片描述

我怎样才能实现这个目标?

答案1

你可以说shorten你自己的台词。

缩短

\documentclass{article}\usepackage{xcolor} \usepackage[most]{tcolorbox}

\tikzset{crossout/.style={thick,red,shorten >=-.5cm,shorten <=-.5cm}}

\begin{document}

Of course, presenting this solution would be cheating. And, no, it won't work in all cases, due to strict limitations on the pairs 
\tcbox[tcbox raise base,
breakable,nobeforeafter, enhanced jigsaw, opacityback=0, sharp corners, parbox=false, boxrule=0pt, top=0pt,bottom=0pt,left=0pt,right=0pt, boxsep=0pt, frame hidden, parbox=false, 
  finish={\draw[crossout] (frame.south west)--(frame.north east);\draw[crossout] (frame.south east)--(frame.north west);}]{
  accepted
  }
  by \textbackslash{}line. Your professor surely knows that TeX doesn't draw oblique lines. With the standard package pict2e it's easier and it will work in any case.

\end{document}

答案2

一种替代的 TikZ 解决方案(不如 TeXnician 的解决方案优雅)。

overlay可以在上面书写内容而不占用空间。

我曾经用它shift来放大线条(您shorten也可以在这里使用,但我没有使用它,因为 TeXnician 已经这样做了,因此我想展示一种替代方法)。

要将 TikZ 节点与普通文本对齐,请参见此处:普通文本中的 TikZ 节点

\documentclass{article}\usepackage{xcolor} \usepackage{tikz}
\newcommand{\mycrossed}[1]{%
    \tikz[remember picture, baseline=(A.base)]{
        \node[inner sep=0pt](A){#1};
        }%
    \tikz[overlay, remember picture]{
        \draw[red, very thick] ([shift={(-.5,.2)}]A.north west) -- ([shift={(.5,-.2)}]A.south east);
        \draw[red, very thick] ([shift={(-.5,-.2)}]A.south west) -- ([shift={(.5,.2)}]A.north east);
        }%
    }
\begin{document}

Of course, presenting this solution would be cheating. And, no, it won't work in all cases, due to strict limitations on the pairs 
\mycrossed{accepted}
  by \textbackslash{}line. Your professor surely knows that TeX doesn't draw oblique lines. With the standard package pict2e it's easier and it will work in any case.
\end{document}

在此处输入图片描述

答案3

2019 年 5 月(pgf 版本 3.1.3) tikz 的库中已经有删除线形状了shapes.misc

以下代码和图形取自手册第 71.8 节。

\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
\node [cross out,draw=red] at (1.5,1) {cross out};
\end{tikzpicture}

在此处输入图片描述

相关内容