This solution involves closing off your \uline
and \sout
invocations as you approach an invocation of \citep
. For those references, use \ulineref
and \soutref
as defined in this MWE. Then, pick up the \uline
and \sout
where you left off, after the reference. The reference itself will not break across a line, though of course the \uline
and \sout
will.
The solution here adapts the censor
package to do both underlining and strikeout. The depths of the lines can be changed with the \censorruledepth
, as used in the \ulineref
and \soutref
macros. I tried to match those value to the existing line depths of the ulem
package.
\documentclass{article}
\usepackage{ulem}
\usepackage{censor}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{filecontents}
\usepackage{calc}
%%%%%%%%%%%
\censorruleheight=.1ex %THICKNESS OF CENSOR RULE
\newlength\nextcharwidth
\makeatletter
\renewcommand\@cenword[1]{%
\setlength{\nextcharwidth}{\widthof{#1}}%
\censorrule{\nextcharwidth}%
\kern -\nextcharwidth%
#1}
\makeatother
\newcommand\ulineref[1]{\censorruledepth=-.67ex\censor{#1}}
\newcommand\soutref[1]{\censorruledepth=.55ex\censor{#1}}
%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@article {MCOSW,
author = "Hugh Glaser and Afraz Jafri and Ian Millard",
title = "Managing co-reference on the semantic web",
journal = "WWW2009 Workshop: Linked Data on the Web (LDOW2009)",
month = "April",
year = "2009",
%
@article {MCOSX,
author = "Hugh Glaser and Afraz Jafri and Ian Millard",
title = "Managing co-reference on the semantic web",
journal = "WWW2009 Workshop: Linked Data on the Web (LDOW2009)",
month = "April",
year = "2009",
%
@article {MCOSY,
author = "Hugh Glaser and Afraz Jafri and Ian Millard",
title = "Managing co-reference on the semantic web",
journal = "WWW2009 Workshop: Linked Data on the Web (LDOW2009)",
month = "April",
year = "2009",
}
\end{filecontents}
\begin{document}
I will begin the underline
\uline{sentence1 }%
\ulineref{\citep{MCOSW}}%
\uline{, sentence continued onto next line. }%
\ulineref{\citep{MCOSX,MCOSY}}%
\uline{ blah blah}
followed by normal text
I will begin the strikeout
\sout{sentence1 }%
\soutref{\citep{MCOSW}}%
\sout{, sentence continued onto next line. }%
\soutref{\citep{MCOSX,MCOSY}}%
\sout{ blah blah}
followed by normal text
\bibliography{\jobname}
\end{document}
I used soul
to do the strikethrough, but had to define a displayst
command to do strikethrough in display math mode. (soul
commands only work with math as in \st{$abc$}
. . . ) I also used the solution from Why is it that coloring in soul in beamer is not visible to make the color work. Use \setul{⟨underline depth⟩}{⟨underline thickness⟩}
to change thickness of underline/strikethrough in soul
.–
\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{color,soul}
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\makeatother
\setstcolor{red}
%\setul{}{1pt} Use this to change weight of underline/strikethrough
\newcommand{\displayst}[1]{\textrm{\SoulColor\st{$\displaystyle#1$}}}
\begin{document}
\begin{frame}
\begin{align*}
P = \{ & \displayst{S\rightarrow X_{1,4,2}}\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1},\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1}\}
\end{align*}
\end{frame}
\end{document}
Result:
Edit
I guess making this work nicely with soul
required fixing a few things. The original solution I posted strikes behind the text, instead of on top of it, but this was solved in Strikeout in different color appears behind letters, not on top of them
\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xparse,xcolor,soul}
%% First define strikethrough command that strikes on top of letters, not behind them
\makeatletter
\NewDocumentCommand{\sttwo}{O{red}O{black}+m}
{%
\begingroup
\setulcolor{#1}%
\setul{-.5ex}{1pt}% <---- sets the undline/strikeout weight to 1pt
\def\SOUL@uleverysyllable{%
\rlap{%
\color{#2}\the\SOUL@syllable
\SOUL@setkern\SOUL@charkern}%
\SOUL@ulunderline{%
\phantom{\the\SOUL@syllable}}%
}%
\ul{#3}%
\endgroup
}
\makeatother
% Now make soul colors work with beamer
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\makeatother
%Now make a version of strikethrough that works with display math
\newcommand{\displayst}[1]{\textrm{\SoulColor\sttwo{$\displaystyle#1$}}}
\begin{document}
\begin{frame}
\begin{align*}
P = \{ & \displayst{S\rightarrow X_{1,4,2}}\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1},\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1}\}
\end{align*}
\end{frame}
\end{document}
Result:
Best Answer
This just puts a paragraph parsing wrapper around
\xout
and\sout
, given as\xoutpars
and\soutpars
.However, this will not address things like math, etc.