From fbaf3fc84d886b215b522a4eb14ff8bcdfc287f0 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Thu, 30 Aug 2012 14:09:23 +0200 Subject: [PATCH] Protect underlined \ref{} commands by enclosing them in \mbox{}. This is the same protection used for \cite{}. Although "ulem" commands don't strictly need this protection with \ref{} and friends, this helps when one wants to use another package souch as "soul". Indeed, ulem's \uline{} doesn't hyphenate words, while soul's \ul{} does, and thus the output is much nicer. With this patch, replacing ulem with soul is as simple as adding \usepackage{soul} \renewcommand{\uline}[1]{\ul{#1}} to the preamble, without worrying about manually enclosing in \mbox the \ref commands. In any case, the output from ulem remains unchanged. Another possibility offered by soul is that of typesetting as "yellow highlighted" the underlined text. This is achieved by adding \usepackage{color,soul} \renewcommand{\uline}[1]{\hl{#1}} to the preamble. (cherry picked from commit 91afc2430d056e5cbf0065ac0d1a754a2a2ff384) --- src/insets/InsetRef.cpp | 6 ++++++ status.20x | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index cd00e0d023..9f606ff0a2 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -142,6 +142,9 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const string const cmd = getCmdName(); docstring const data = getEscapedLabel(rp); + if (rp.inulemcmd) + os << "\\mbox{"; + if (cmd == "eqref" && buffer().params().use_refstyle) { os << '(' << from_ascii("\\ref{") << data << from_ascii("})"); } @@ -159,6 +162,9 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const p["reference"] = ref; os << p.getCommand(rp); } + + if (rp.inulemcmd) + os << "}"; } diff --git a/status.20x b/status.20x index 029bfcc739..7f51249be6 100644 --- a/status.20x +++ b/status.20x @@ -32,6 +32,9 @@ What's new - Add support for some IPA diacritics. +- Enclose underlined \ref{} commands in \mbox{} to protect them when + using the package soul in place of (or together with) ulem. + * TEX2LYX IMPROVEMENTS