4

enter image description here 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?

2

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}

enter image description here

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{}.

2

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}

enter image description here

  • +1, but there are two flaws. First, #2 is 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 8 '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 8 '16 at 14:33
  • 1
    @HenriMenke The slash is certainly bigger than the digits, so the \vphantom sets 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 8 '16 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.