% % U L E M . S T Y % % A style file to provide underlining that can stretch and be broken between % lines. It replaces italics with underlining in \em-phasized text. % It is most suitable for simple text such as {\em ibid.} or {\em \LaTeX: % A Document Preparation System\/} that may need to be underlined in a % manuscript submitted for publication. Only to be used when emphasis % is delimited by braces. % % So you want to do some underlining but still want \em to give italics? % Just enter the declaration \normalem before beginning your document % and specify your underlining as \uline{some text} (alias \ULine also). % \uline also works in plain TeX, just \input ulem.sty. If you use this % method of underlining a lot, you might want to abbreviate the definition, % changing \ULine or \uline to \ul. % % Methods for wavy-underlines, striking out, or marking over text are % also shown as comments. In summary: % \uline{important} % underlined text % \uwave{boat} % wavy underline % \sout{wrong} % line drawn through word % \xout{removed with hash marks}% marked over with //////. % If underlining for emphasis is switched on (default) then % {\em emphasized\/} is underlined; % declare \normalem to turn this off, \ULforem to turn it back on. % To replace boldface (\bf) with wavey underlines, put \UWforbf in the % preamble. % % More instructions after \endinput. % % Copyright (c) 1989,1992,1993 by Donald Arseneau % % These macros may be freely transmitted, reproduced, or modified for % non-commercial purposes provided that this notice is left intact. % Defend against multiple loading. \expandafter \ifx \csname UL@box\endcsname \relax \else \endinput \fi % Set catcode of @ in case it isn't a "letter" already \expandafter\edef\csname UL@catcode\endcsname {\catcode`\noexpand\@=\the\catcode`\@ \let \csname UL@catcode\endcsname \noexpand\UnDefinedButNoAt} \catcode`\@=11 % Allow plain TeX to use this style: \ifx\@ifundefined\@underfined \def\@height{height} \def\@depth{depth} \def\@width{width} \def\@empty{} \def\@gobble#1{} \let\pem\it \let\pbf\bf % Do non-outer \newif with no visible \if's or \fi's when skipping \csname newif\expandafter\endcsname \csname if@ignore\endcsname \fi % For underlining normally \def\ULem{\let\pem\LA@em \expandafter\UL@set\expandafter{\ifnum0=`}\fi}%% -> \UL@set{ \def\ULine{\bgroup\UL@set} \let\uline\ULine \let\LA@em\pem \def\ULforem{\let\pem\ULem} \def\normalem{\let\pem\LA@em} \ULforem % default is to use underlining for \em, \newbox\UL@hyphenbox \newbox\UL@box %% \newcount\UL@penalty % use \@clb for penalty holder -- no conflicts \newskip\UL@skip \newdimen\UL@ldp \def\ULthickness{.4pt}% can change this with \renewcommand % % Could do this... % \UL@ldp=1.2pt % \def\UL@set{\dimen@-\UL@ldp \advance\dimen@\ULthickness \UL@on} % ...see note a few lines down and definition of \sout \let\LA@space\ \let\LA@hskip\hskip \def\UL@end*{\relax\relax}% something harmless unlikely to be found elsewhere % Set the depth of the underline. For a different depth, \UL@set should % be changed so \UL@ldp is retained--the value is a style parameter. % For non-underlining applications, \UL@set should be bypassed and some % other macro should make any necessary settings (see \sout). % \def\UL@set{\setbox\UL@box\hbox{(}\UL@ldp\dp\UL@box \dimen@-\UL@ldp \advance\dimen@\ULthickness \UL@on} \def\UL@on#1{\leavevmode\everymath{\UL@hrest}\let\-\UL@dischyp \let\ \UL@space \let\hskip\UL@hskip \let\\\UL@cr \let\newline\UL@newline \let\@lnbk\UL@lnbk \let\@nolnbk\UL@nolnbk \def\hfil{\hskip\z@ plus1fil\relax}\def\hfill{\hskip\z@ plus1fill\relax}% \def\hss{\hskip\z@ plus1filminus1fil\relax}% \setbox\UL@hyphenbox\hbox{\setbox\UL@box\hbox{\char \ifnum \hyphenchar\font<\z@ `\-\else \hyphenchar\font\fi }\UL@putbox}\UL@word#1\xdef\UL@spfactor{\the\spacefactor} \UL@end* } \let\UL@unegroup\@empty \def\UL@word#1 {\UL@start.#1 \ifx\UL@end#1\egroup % must expand to nothing ... % outside the ifs for syntactical spaces to work \unskip \unskip \unskip % remove extra leader at end \spacefactor\UL@spfactor \let\UL@word\egroup \else % not finished \ifmmode\else \ifdim\lastskip=\z@\else % this should allow syntactical \global\UL@skip\lastskip \unskip % ...spaces \UL@stop \UL@leaders \fi\fi \fi \UL@word} \def\UL@start.{\setbox\UL@box\hbox\bgroup\everyhbox{\UL@hrest}% % the following are to cope with stops (\ ,\- etc) within extra braces \let\UL@start\@gobble \let\UL@putbox\@empty \let\UL@unegroup\bgroup \kern-3sp\kern3sp % kerns so I can test for beginning of list \if@ignore \global\@ignorefalse \expandafter\ignorespaces \fi} \def\UL@stop{\global\@clb\lastpenalty % store penalty in \@clb; no \cline here! \ifdim\lastkern=3sp \egroup % Nothing in hbox, \ifdim\wd\UL@box=\z@ % make doubly sure, and don't put on list \else \UL@putbox \fi \else \egroup \UL@putbox \fi\UL@unegroup} \def\UL@putbox{{\UL@skip\wd\UL@box \advance\UL@skip\UL@pixel \vrule \@height\dimen@ \@depth\UL@ldp \@width\UL@skip \kern-\UL@skip}\box\UL@box \ifnum\@clb=\z@ \else \penalty\@clb \fi} % With interword leaders, give some overlap to avoid gaps caused by % round-off errors in the printing program. Needs \unskip \unskip \unskip % above. This version assumes 300 dots per inch, but it still looks good % with higher resolution, and will still work down to ~150 dpi. Change the % value of \UL@pixel if necessary. \newdimen\UL@pixel \UL@pixel=0.0033333truein \def\UL@leaders{{\LA@hskip-\UL@pixel \advance \UL@skip \tw@\UL@pixel \leaders\hrule \@height\dimen@ \@depth\UL@ldp \LA@hskip\UL@skip \LA@hskip-\UL@pixel}} % restore some things for inside math or \mbox \def\UL@hrest{\let\ \LA@space \let\-\@empty} \def\UL@space{\LA@space \global\UL@skip\lastskip \unskip \UL@reskip} \def\UL@dischyp{\penalty\z@ % zero penalty => no break (see \UL@stop) \UL@stop \discretionary{\copy\UL@hyphenbox}{}{}\UL@start.} % The test \ifx\ \LA@space \else means we are neither in math mode nor an % \mbox, so it is safe to stop the current \UL@box. \ and \- are common % enough that they are disabled directly (by \UL@hrest); \\, \newline, \hskip, % \linebreak, and \nolinebreak are rare enough that the test is incorporated % in their UL versions. This adds processing when they're used, but saves % processing in \UL@hrest called by \everymath and \everyhbox. \def\UL@hskip{\ifx\ \LA@space \else \afterassignment\UL@reskip \global\UL@skip \fi} \def\UL@reskip{\UL@stop \UL@leaders \UL@start.} \def\UL@cr{\unskip \ifx\ \LA@space \else \UL@stop \fi \unskip\unskip\unskip \@normalcr} \def\UL@newline{\ifx\UL@start\@gobble % (\UL@cr may have \UL@stop-ed already) \unskip \ifx\ \LA@space \else \UL@stop \fi \fi \unskip\unskip\unskip \LA@hskip \z@ plus1fil\penalty -\@M \UL@start.} \def\UL@lnbk[#1]{\ifx\ \LA@space \else \unskip \UL@stop \unskip\unskip\unskip \penalty -\@getpen{#1}\UL@start.\fi} \def\UL@nolnbk[#1]{\ifx\ \LA@space \else \global\UL@skip\lastskip \unskip \UL@stop \ifdim \lastskip=-\UL@pixel \unskip \global\UL@skip\lastskip \unskip\unskip \fi \penalty \@getpen{#1}\ifdim\UL@skip=\z@\else\UL@leaders\@ignoretrue\fi \UL@start.\fi} %--------begin optional features------- % Remove the (first) % from each of the following lines to enable wavey % underlines, crossing out, or other added features. % % % For drawing a wavey underline instead of a straight one (under-wave) % % use tilde (\sim) as an underline character: % % \def\uwave{\bgroup\UW@set} % \def\UWbf{\let\pbf\LA@bf % \expandafter\UW@set\expandafter{\ifnum0=`}\fi}%% -> \UW@set{ % \let\LA@bf\pbf % \def\UWforbf{\let\pbf\UWbf} % \def\normalbf{\let\pbf\LA@bf} % % % To draw a line through text instead of under it (strike out) % % do `under' line with line height set higher: % % \def\sout{\bgroup \UL@ldp-.5ex \dimen@-\UL@ldp % \advance\dimen@\ULthickness \UL@on} % % % To mark //// over text instead of underlining (x-out) % \def\xout{\bgroup \markoverwith{/}\UL@on} % % \def\UW@set{\markoverwith{\lower1ex\hbox{\the\scriptfont\tw@ % \char"18\kern.02em}}\UL@on} % % \def\UW@leaders{\LA@hskip-\UL@pixel\UW@leadtwo} % % \def\UW@leadtwo{{\advance\UL@skip\tw@\UL@pixel % \leaders\copy\UW@box\LA@hskip\UL@skip}\LA@hskip-\UL@pixel} % % \def\UW@putbox{\vrule\@width-\UL@pixel \penalty\@M % {\UL@skip\wd\UL@box \UW@leadtwo}\kern-\wd\UL@box \box\UL@box % \ifnum\@clb=\z@ \else \penalty\@clb \fi} % % \newbox\UW@box % % \def\markoverwith#1{\let\UL@leaders\UW@leaders \let\UL@putbox\UW@putbox % \setbox\UW@box\hbox{\kern-.1em#1\kern-.1em}% % \UL@pixel.5\wd\UW@box} % character size acts like a pixel size %-------end optional features-------- \UL@catcode % restore catcode of @ to starting value \endinput % % ULEM changes the behavior of \em to underline emphasized text; and it % also enables underlining with the syntax \ULine{some text}. Although % ULEM is far from a perfect replacement for \em, it does allow line % breaks, and even primitive hyphenation, within the underlined text. % It is most suitable for simple text that may need to be underlined in % a manuscript submitted for publication. It is *only* to be used when % emphasis is delimited by explicit braces. The thickness of the rule % is given by \ULthickness; use \renewcommand to change it. The depth is % controlled by the current font. See the definition of \UL@set. % % Every word is typeset in an underlined box, so automatic hyphenation is % normally disabled, but explicit discretionary hyphens (\-) will still be % obeyed. The underlines continue between words, and stretch just like % ordinary spaces do. Since spaces delimit words, there may be some % difficulty with syntactical spaces (e.g. "2.3 pt"). Some effort is made % to handle such spaces, but if that fails, you might solve the problem by % enclosing the offending command in braces... % % One important incompatability is with grouping: EVERYTHING IN BRACES % IS TREATED LIKE AN MBOX. Thus, braces will suppress stretching and % linebreaks in the text they enclose. Moreover, the specially-taken- % care-of commands \-, \\, \newline and \linebreak are often ignored if they % appear inside extra braces. They succeed only if the enclosing braces are % preceded and followed by spaces; but then those commands have another % undesireable effect: they end the group and start a new one! Thus, you % should only have braces around simple text, or for delimiting parameters % to commands. Syntactical spaces inside braces never cause a problem, % nor do spaces in math mode. % % Text produced by expansion of a command word is boxed too, but \\, \ % and \- still work in the expansion text; just as for braces surrounded % by space: % \newcommand\iff{if and only if} {\em \iff} % does not allow any stretching or linebreaking between words, but % \newcommand\iff{if\ and\ only\ if} {\em \iff} % allows stretching and linebreaking. % % Supported formatting commands are \\, \newline, \linebreak, \nolinebreak, % \penalty, \hskip, \hspace, \hfil, \hfill, \hss, \ , \-, and ~. Displayed % math and \par are deliberately not supported to aid in the detection of % runaway arguments (missing braces). % % Nested \em commands produce underlined italics, but heed the warnings % about braces above. Since nested \em-phasis normally switches back to % roman type, this is another incompatability. To get italics without % underlining, use \it. % % HERE IS A SIMPLE EXAMPLE. % % \noindent 'Twas {\em brillig\/} and the {\em slithy~toves\/} % did {\em gyre\/} and {\em gim\-ble\/} in the {\em wabe,\\[2pt] } % All {\em mim\-sey\/} were the {\em boro\-goves\/} and % the {\em mome raths outgrabe}. % % HERE IS A DIFFICULT EXAMPLE. % % \documentstyle[12pt,ulem]{article} % or [ulem] % \setlength\textwidth{3.3in} % \begin{document} % No, I did {\em not} act in the movie {\em {\em The} % <<<<<<< Nested % {\em Persecu\-\em tion} {\em and} {\em Assassination} {\em of} % {\em Jean-Paul} {\em Marat}, as per\-formed by the Inmates % of the Asylum of Charenton under the Direc\-tion of the % Marquis de~Sade!} But I {\em did} see it. % \end{document} % % In the nested emphasis, \em is given for each word so that the % interword spaces can be outside the braces. Otherwise, there would be % no stretch to the line. Note that the discretionary hyphen (\-) in % Persecution cancelled the inner \em, thus \-\em was needed, but the % hyphen in Direction was just fine because it was not in nested braces. % Whew! This example illustrates that ULEM does not handle nested % emphasis well! Nevertheless, it works great for simple things. % % Underlining can also be done according to \uline{this text}. To use % this type of underlining, but have \em still produce italics, put % \normalem in the preamble of the document. % % Other variations are possible, including drawing a wavey underline % (\uwave{under-wave}) instead of a straight one, drawing a line through % text rather than under it (\sout{strike out}), crossing out text with % /////// (\xout{cross out, X out}), plus whatever variations you can % think of. These variations are commented-out in the standard % distribution, so remove the % from the appropriate lines to enable % these features. To get wavy underlines for {\bf }, un-comment % the definitions for \uwave, and put \UWforbf at the beginning of % your document. % % Version 1992: make " {} " give two spaces, as it should; support \newline % and \\, \nolinebreak and \linebreak; add definitions necessary for % plain TeX use. Support various types of `underline'. % 1992a: fix definition of \hfill for plain TeX (found by Esther Hu). % The bug finders' fee is now $0.00; it will double for each new bug found. % 1993: Use fewer registers, support \hss. Changed \kern\leaders\kern % to \hskip\leaders\hskip because there was an unwanted breakpoint at % the first kern. Avoid error when hyphenation is disabled (found by Lones % Smith). % % Send problem reports to asnd@reg.triumf.ca % % test integrity: % brackets: round, square, curly, angle: () [] {} <> % backslash, slash, vertical, at, dollar, and: \ / | @ $ & % hat, grave, acute (apostrophe), quote, tilde, under: ^ ` ' " ~ _