2

I need to use \sout{} from the ulem package for longer passages of text and in combination with other macros. However, this removes all linebreaks and the text is kept on a single line. Is there any way to get proper line breaks back? (Perhaps an alternative to \sout{}?)

Here's an example:

\documentclass{article}
\usepackage{ulem}

\textwidth=5cm
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\newcommand{\dialogue}[2]{\hangindent=5.2em\makebox[5em][l]{#1:}\hspace{0.2em}#2}

\begin{document}
\sout{This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. }

\dialogue{Person}{This is a long text. This is a long text. This is a long text. This is a long text. This is a long text.}

\sout{\dialogue{Person}{This is a long text. This is a long text. This is a long text. This is a long text. This is a long text.}}

\end{document}

This is what the result looks like: Sout with macros example, with missing line breaks

Without any macros, sout{} works fine, but with any macro, including my example of \dialogue{} above, it breaks. Is there any way to get the bottom case to break lines?

6
  • Use a declaration instead: \sout{\bfseries This is a long text. This is a long text. This is a long text. This is a long text. This is a long text.}
    – Ivan
    Apr 26, 2021 at 9:23
  • Thanks -- yes, that would solve this MWE, but not my actual problem, where I have a more complex macro inside (edited the question to make it clearer).
    – Tuetschek
    Apr 26, 2021 at 9:50
  • Without knowing what macro it is it is difficult to help you (please add it to your MWE). However you can try to reverse the order of the macros. This works the same: \textbf{\sout{This is a long text. This is a long text. This is a long text. This is a long text. This is a long text.}}
    – Ivan
    Apr 26, 2021 at 9:53
  • OK I've added my macro – but based on the reply below, it looks like the only solution is to always use \sout{} as the innermost thing.
    – Tuetschek
    Apr 26, 2021 at 17:24
  • Maybe soulpos can help (caveat: I'm the author). Apr 26, 2021 at 17:32

1 Answer 1

2

Chapter 3 of the ulem documentation does not solve your problem, but explains the reason. There it is stated (amongst others):

One important incompatibility with braces and macro replacement: All the text in braces or coming from a macro is typeset in a box (as if in \mbox). Consequently, braces will suppress stretching and line-breaking in the text they enclose. Moreover, the specially-handled commands \-, \\, \newline and \linebreak are usually ignored if they appear inside extra braces. They operate only when the braces delimit a command parameter without introducing a level of grouping.

The solution of Ivan does work indeed, but not for the "box" of the lipsum.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .