Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently using ulem and \sout to do strikethroughs, but what if I want to strikethrough in a section title?

I'm using hyperref and receive the following error when I use \section{\sout{..}}:

Argument of \UL@word has an extra }.

Does anyone know how to do this?

share|improve this question
    
I don't appreciate the edits to this question. I don't see how removing my thanks was necessary or even appropriate. –  BBischof Jul 5 '11 at 19:25
3  
My apologies, but closing texts are not wanted on this site (or any stackexchange site) in general. Also some opening texts are even automatically removed by the system. I removed it as usual when I formatted your post. (I actually didn't saw your comment before my second edit.) –  Martin Scharrer Jul 5 '11 at 19:40
1  
It's listed on the guidelines on the Welcome to TeX.SX! page for once, but this post is relative new and also shouldn't be used for discussions. I'm looking for a better one at the moment, also on meta site meta.stackexchange.com. –  Martin Scharrer Jul 5 '11 at 19:46
1  
Found it: Should 'Hi', 'thanks' and taglines and salutations be removed from posts? and also Are taglines & signatures disallowed?, it is also in the FAQ (at least about signatures and tag-lines, but it also applies to other similar text). Keep in mind that this page is a Q&A Wiki, not a forum, so edits by other users are common and wanted in general. –  Martin Scharrer Jul 5 '11 at 19:47
1  
@doncherry: "Does anyone know how to do this?" is on the border, but sounded very much a repetition of but what if I want to strikethrough in a section title?. I put it back in. There is a system which notifies users on already done edits, but they work asynchronous and do not fully work when two edits are saved shortly after each other (10 sec here). –  Martin Scharrer Jul 5 '11 at 20:35
show 3 more comments

2 Answers 2

up vote 6 down vote accepted

As always you need to take extra care when using macros in moving arguments like section titles. They are written to the ToC and with hyperref also to the PDF bookmarks which only take text and no formatting.

Make sure to \protect all macros (\sout is already protected). The solution in Why hyperref doesn't like commands set via \let in section titles? didn't worked, but using \texorpdfstring does. I recommend to use an own wrapper macro which uses \texorpdfstring internally and is defined using \DeclareRobustCommand (or \protected\def):

\documentclass{article}

\usepackage{ulem}
\usepackage{hyperref}
\usepackage{nameref}

\DeclareRobustCommand{\hsout}[1]{\texorpdfstring{\sout{#1}}{#1}}

\begin{document}
\tableofcontents

\section{\hsout{Striked out section title}}\label{foo}

\ref{foo}

\autoref{foo}

\nameref{foo}

\end{document}
share|improve this answer
add comment

You can do this by putting \sout inside of \section:

\documentclass{article}

\usepackage{ulem}

\begin{document}

\section{\sout{Striked out part} of a section title}

\end{document}

Striked out part of a section title

Making it work with hyperref

To make this work with hyperref either use \texorpdfstring as in

\section{\texorpdfstring{\sout{Striked out part}}{Striked out part} of a section title}

or use the optional argument of \section as in

\section[Striked out part of a section title]{\sout{Striked out part} of a section title}
share|improve this answer
    
I tried this... –  BBischof Jul 5 '11 at 19:18
    
@BBischof It compiles alright on my system (TeX Live 2009) and looks alright. What is the problem? –  N.N. Jul 5 '11 at 19:20
1  
Doesn't work with hyperref, at least not out-of-the-box –  Martin Scharrer Jul 5 '11 at 19:24
1  
@BBischof,@N.N.: related to this issue: tex.stackexchange.com/questions/22215/…. Try using the optional argument of \section without \sout. –  Martin Scharrer Jul 5 '11 at 19:28
5  
My suggestion: \DeclareRobustCommand{\hsout}[1]{\texorpdfstring{\sout{#1}}{#1}} and use \hsout instead. –  Martin Scharrer Jul 5 '11 at 19:33
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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