14

What I would like to do is to make corrections to a document- to cross out some text using the ulem package and then to put the "correct" answer above it.

e.g.

\dotuline{\fontfamily{augie}\selectfont{nach den}} Türkei

yields a handwritten answer on a dotted line. Using \usepackage{ulem}, this can be struck out:

\dotuline{\sout{\fontfamily{augie}\selectfont{nach den}}} Türkei

but I would also like to put in the corrected answer above the text, preferably without having to go into math mode and using \atop.

Any ideas?

azetina
  • 28,884
  • Welcome to TeX.SX! Four spaces of indent will format your code to look like code. Also, is the answer "nach dem"? My high school German is so rusty. – Matthew Leingang Jan 19 '11 at 14:21

2 Answers2

13

can also be done with a simple tabular

\documentclass{article}
\usepackage{xcolor,calc}

\newcommand\strikeout[2][]{%
 \begin{tabular}[b]{@{}c@{}} 
    \makebox(0,0)[cb]{\textcolor{blue}{#1}} \\[-0.2\normalbaselineskip]
     \rlap{\color{red}\rule[0.5ex]{\widthof{#2}}{0.5pt}}#2
 \end{tabular}}

\begin{document}

Now is the the time for all good \strikeout[citizens]{men} to come to the aid of 
their \strikeout{their} country.

\end{document}

alt text

10

You might be interested in the cancel package. Or something similar can be implemented in TikZ.

\documentclass{article}
\usepackage{tikz}

\newcommand{\strikeout}[2][]{%
    % usage: \strikeout[bar]{foo} strikes out foo and superimposes bar
    %        \strikeout{foo} strikes out foo.
    \begin{tikzpicture}[baseline=0]
        \node[anchor=base,inner sep=0pt,outer sep=0pt] (main) {#2};
        \draw[red] ([yshift=0.5ex]main.base west) -- ([yshift=0.5ex]main.base east);
        \node[overlay,anchor=south,blue] at (main.north) (correction) {#1};
    \end{tikzpicture}%
}

\begin{document}

Now is the the time for all good \strikeout[citizens]{men} to come to the aid of their \strikeout{their} country.

\end{document}

sample

Matthew Leingang
  • 44,937
  • 14
  • 131
  • 195
  • Thank you for the welcome and the suggestion! The correct answer should be just "nach" :-). The cancel package helps me with a problem I didn't mention, in that it allows me to change the colour with which I strike things out, but it doesn't help me with writing in the correct answers above the ones that have been struck out. I've never used TikZ, but it looks a bit tricky! Is there nothing simpler? Thank you very much for your help! –  Jan 19 '11 at 14:49
  • oops sorry just saw your code. Thankyou!! –  Jan 19 '11 at 15:17
  • @JTzara: Oh, I get it, the issue is not which case of article but whether an article is necessary at all. You caught me between suggesting a method and coding it up. Hope it helps. – Matthew Leingang Jan 19 '11 at 15:56
  • How would you modify the above to get a bolder cross-out line (e.g. for use with larger font size)? Could I use the "cancel" package in place of the "draw" command to get a diagonal slash through the text? (Adding \cancel{#2} gives an error that the node must allow for a possibly empty argument). – cboettig Aug 01 '12 at 19:58