3

I need to cross out a word with a wavy line in LaTex. I used ulem package but the result was underlined word with a wavy line. This is my code so far:

\documentclass{article}
\usepackage{pict2e}
\usepackage[normalem]{ulem}
\makeatletter
\newcommand{\crossout}[1]{%
  \begingroup
  \settowidth{\dimen@}{#1}%
  \setlength{\unitlength}{0.05\dimen@}%
  \settoheight{\dimen@}{#1}%
  \count@=\dimen@
  \divide\count@ by \unitlength
  \begin{picture}(0,0)
  \put(0,0){\line(20,\count@){20}}
  \put(0,\count@){\line(20,-\count@){20}}
  \end{picture}%
 #1%
  \endgroup
}
\begin{document}
The most \uwave{\hspace{1cm}}\crossout{powerful} processor in your  \crossout{computer} is probably the graphics processor 
\end{document}
Arash Esbati
  • 7,416
Sarah
  • 113

3 Answers3

1

Define this command with the ulem package:

\newcommand{\waveout}[1]{\raisebox{4pt}{\uwave{\phantom{#1}}}\llap{#1}}

and use it as \waveout{word}

\documentclass{article}
\usepackage{pict2e}
\usepackage[normalem]{ulem}
\pagestyle{empty}
 \makeatletter
 \newcommand{\crossout}[1]{%
 \begingroup
 \settowidth{\dimen@}{#1}%
 \setlength{\unitlength}{0.05\dimen@}%
 \settoheight{\dimen@}{#1}%
  \count@=\dimen@
 \divide\count@ by \unitlength
  \begin{picture}(0,0)
  \put(0,0){\line(20,\count@){20}}
 \put(0,\count@){\line(20,-\count@){20}}
  \end{picture}%
 #1%
  \endgroup
}
\begin{document}
\newcommand{\waveout}[1]{\raisebox{4pt}{\uwave{\phantom{#1}}}\llap{#1}}

The most powerful processor in your  \waveout{computer} is probably the     graphics \waveout{processor}
\end{document}

enter image description here

  • I want the word to be crossed out by drawing 2 wavy lines to cross it. Thanks for you reply – Sarah May 19 '15 at 17:25
1

A different approach using TikZ:

\documentclass[a4paper,11pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\newcommand{\crossout}[1]{\raisebox{-0.2mm}{%
    \tikz{\draw(0,0) node[anchor=west,inner sep=0,text depth=0.2mm](crossedWord){#1};
        \draw[decorate,decoration={snake,amplitude=1pt}](crossedWord.west) -- (crossedWord.east)
    }}}
\begin{document}
The most \crossout{powerful} processor in your \crossout{computer} is probably the graphics processor.
\end{document}

This gives the result below, and the size of the waves can be adjusted by changing the amplitude argument. Crossouts using TikZ

EDIT: To draw two waves, the command below may be used.

\documentclass[a4paper,11pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc}
\newcommand{\crossout}[1]{\raisebox{-0.2mm}{%
    \tikz{\draw(0,0) node[anchor=west,inner sep=0,text depth=0.2mm](crossedWord){#1};
        \draw[decorate,decoration={snake,amplitude=1pt}](crossedWord.west) -- (crossedWord.east);
        \draw[decorate,decoration={snake,amplitude=1pt}]($(crossedWord.west)+(0,-1.5pt)$) -- ($(crossedWord.east)+(0,-1.5pt)$);
    }}}
\begin{document}
The most \crossout{powerful} processor in your \crossout{computer} is probably the graphics processor.
\end{document}

This will result in the following output. Double waves using TikZ

SECOND EDIT: After some misunderstandings about how the words should be crossed out, here is a TikZ-version to create an "X-type" crossout with wavy lines.

\documentclass[a4paper,11pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\newcommand{\crossout}[1]{\raisebox{-0.2mm}{%
    \tikz{\draw(0,0) node[anchor=west,inner sep=0,text depth=0.2mm](crossedWord){#1};
        \draw[decorate,decoration={snake,amplitude=1pt}](crossedWord.north west) -- (crossedWord.south east);
        \draw[decorate,decoration={snake,amplitude=1pt}](crossedWord.south west) -- (crossedWord.north east);
    }}}
\begin{document}
The most \crossout{powerful} processor in your \crossout{computer} is probably the graphics processor.
\end{document}

Wavy X-crossout using TikZ

1

REVISED ANSWER based on OP reply to "original answer".

This produces squiggly x-shaped crossout through individual words. Rather than perform the trigonometry to calculate the squiggle angle, I set up a series of dimensional comparisons. More can be added if needed.

\documentclass{article}
\usepackage{stackengine,graphicx,xcolor,ulem}
\def\crossout#1{%
  \setbox0=\hbox{#1}%
  \ifdim\wd0<\ht\strutbox\relax\def\xangle{45}\else
  \ifdim\wd0<2\ht\strutbox\relax\def\xangle{30}\else
  \ifdim\wd0<4\ht\strutbox\relax\def\xangle{22}\else
  \ifdim\wd0<6\ht\strutbox\relax\def\xangle{11}\else
  \ifdim\wd0<10\ht\strutbox\relax\def\xangle{5}\else
  \def\xangle{3}%
  \fi\fi\fi\fi\fi
  \def\stacktype{L}\setstackgap{L}{0pt}\def\useanchorwidth{T}%
  \stackon{\stackon[0pt]{#1}{%
  \color{red}\smash{\kern-1pt\rotatebox{\xangle}{\mywave{#1}}}}}{%
  \color{red}\smash{\rotatebox[origin=right]{-\xangle}{\mywave{#1}}}\kern-1pt}}
\def\mywave#1{\raisebox{0.5pt}{\uwave{\phantom{#1}}}}
\begin{document}
The \crossout{most} \crossout{powerful} processor \crossout{in}
your \crossout{computer} is probably the graphics processor. 
Crossout \crossout{a} short word \crossout{and} a 
\crossout{hyper-ridiculously} long
\crossout{supercalifragilisticexpialadocious} word.
\end{document}

enter image description here

enter image description here

ORIGINAL ANSWER

This approach has a pro and a con relative to the other offered answers.

PRO: this method linebreaks; the others do not.

CON: the squiggle is not precise; essentially a scaled $\sim$ is overlaid atop each character in the argument. Thus, the end of one squiggle is not guaranteed to match the beginning of the next. [I put the squiggle in red, so the reader may better understand the level of imprecision]

\documentclass{article}
\usepackage{stackengine,graphicx,xcolor}
\newcommand\chariterate[2][c]{\chariteratehelpA#2 \relax\relax}
\def\chariteratehelpA#1 #2\relax{%
  \chariteratehelpB#1\relax\relax%
  \ifx\relax#2\else\rlap{\charop{~}}\ \chariteratehelpA#2\relax\fi
}
\def\chariteratehelpB#1#2\relax{%
  \charop{#1}%
  \ifx\relax#2\else
    \chariteratehelpB#2\relax%
  \fi
}
\def\charop#1{\def\stacktype{L}\def\useanchorwidth{T}%
  \stackon[0pt]{#1}{\scalebox{.85}[1]{\color{red}$\sim$}}}
\let\crossout\chariterate
\begin{document}
The most \crossout{powerful} processor in your \crossout{computer} is probably the graphics processor 

\crossout{The most powerful processor in your computer is probably the graphics processor, especially extending over two lines.}
\end{document}

enter image description here

Here is a version with a double-squiggly line, as mentioned by the OP in one of the comments.

\documentclass{article}
\usepackage{stackengine,graphicx,xcolor}
\newcommand\chariterate[2][c]{\chariteratehelpA#2 \relax\relax}
\def\chariteratehelpA#1 #2\relax{%
  \chariteratehelpB#1\relax\relax%
  \ifx\relax#2\else\rlap{\charop{~}}\ \chariteratehelpA#2\relax\fi
}
\def\chariteratehelpB#1#2\relax{%
  \charop{#1}%
  \ifx\relax#2\else
    \chariteratehelpB#2\relax%
  \fi
}
\def\squig{\scalebox{.85}[1]{\color{red}$\sim$}}
\def\charop#1{\def\stacktype{L}\def\useanchorwidth{T}%
  \stackon[0pt]{#1}{\stackanchor[3pt]{\squig}{\squig}}}
\let\crossout\chariterate
\begin{document}
The most \crossout{powerful} processor in your \crossout{computer} is probably the graphics processor 

\crossout{The most powerful processor in your computer is probably the graphics processor, especially extending over two lines.}
\end{document}

enter image description here