劃掉與附近單字重疊的單字

劃掉與附近單字重疊的單字

我已經弄清楚如何添加交叉詞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}

在此輸入影像描述

這裡我劃掉了接受這個字。然而,我希望十字架伸出一點,比如說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}

在此輸入影像描述

相關內容