Hello. I want to be able to cross out a number several times (just like in the picture!) at least 3 times. How do i do that? And how do i make a circle around a number?
Asked
Active
Viewed 896 times
4
Pia
- 43
-
welcome! it's courtesy to provide a MWE to show the effort you made. see http://www.tex.ac.uk/FAQ-minxampl.html – naphaneal Jun 08 '16 at 11:25
2 Answers
3
The crossout commands are \crossout, \dcrossout, \tcrossout, and \qcrossout, for 1,2, 3, and 4 strokes respectively.
\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}
While an \fbox would typically be used for a boxed quantity, it seemed from the application that you might want one that is the same width as the original number, so I also provide \shadowbox{}.
Steven B. Segletes
- 237,551
-
Thanks, @Pia. For a circled number, you could use the answer at http://tex.stackexchange.com/questions/233011/greek-symbols-in-box-and-circle – Steven B. Segletes Jun 08 '16 at 13:07
3
You can use \ooalign (one of my favorite tools to play with):
\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}
egreg
- 1,121,712
-
+1, but there are two flaws. First,
#2is going to be typeset in math mode, i.e. in a different font. Second, because the character to be typeset is in the second “row” of\ooalign, the height of the resulting box is determined by the slashes and not by the character, cf.\fbox{\crossout{\displaystyle\int}}. – Henri Menke Jun 08 '16 at 14:31 -
The definition should thus read something like
\newcommand{\crossout}[2][1]{\vphantom{\rslash#2}{\ooalign{\hidewidth$\crosses{#1}$\hidewidth\cr#2\cr}}}– Henri Menke Jun 08 '16 at 14:33 -
1@HenriMenke The slash is certainly bigger than the digits, so the
\vphantomsets the depth accurately; if you need to use this also for deeper and higher symbols, add$#2$in the\vphantom. These are numbers used as numbers, so they should be in math mode. I forgot$in\fbox. – egreg Jun 08 '16 at 14:37

