
答案1
劃掉指令為\crossout
、\dcrossout
、\tcrossout
和\qcrossout
,分別對應 1、2、3 和 4 筆劃。
\documentclass{article}
\usepackage{stackengine}
\newcommand\rawcrossout[2]{\stackengine{0pt}{#1}{#2}{O}{c}{F}{T}{L}}
\def\XX{\kern-3pt/}
\newcommand\crossout[1]{\rawcrossout{#1}{/}}
\newcommand\dcrossout[1]{\rawcrossout{#1}{/\XX}}
\newcommand\tcrossout[1]{\rawcrossout{#1}{/\XX\XX}}
\newcommand\qcrossout[1]{\rawcrossout{#1}{/\XX\XX\XX}}
\newcommand\shadowbox[1]{\setbox0=\hbox{#1}\makebox[\wd0]{\fbox{#1}}}
\begin{document}
\shadowbox{2} \crossout{4} \dcrossout{6} \tcrossout{70} \qcrossout{86}
2 4 6 70 86
\end{document}
雖然 an\fbox
通常用於盒裝數量,但從應用程式看來,您可能需要與原始數字寬度相同的一個,因此我還提供了\shadowbox{}
.
答案2
您可以使用\ooalign
(我最喜歡使用的工具之一):
\documentclass{article}
\newcommand{\crossout}[2][1]{%
\vphantom{\rslash}%
{\ooalign{\hidewidth$\crosses{#1}$\hidewidth\cr$#2$\cr}}%
}
\newcommand{\crosses}[1]{%
\ifcase#1\relax
\or
\rslash\or
\rslash\mskip-5.5mu\rslash\or
\rslash\mskip-5.5mu\rslash\mskip-5.5mu\rslash%
\fi
}
\newcommand{\rslash}{\raisebox{.15ex}{/}}
\begin{document}
\fbox{$2$} \fbox{$3$} \crossout{4} \fbox{$5$} \crossout[2]{6}
\fbox{$7$} \crossout{8} \crossout{9} \crossout[3]{90}
\end{document}