diff options
author | Karl Berry <karl@freefriends.org> | 2010-05-06 15:57:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-05-06 15:57:48 +0000 |
commit | c66689fbbe8c6cb804fd6bcbd98ab7cb61f55f49 (patch) | |
tree | 8d4daef88bb6a57c3d9f5b6eef62cbdb99752ee0 /Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty | |
parent | e6e0312dc87021f1b668acdd44b0b50e91455e5c (diff) |
doc + separate package nolbreaks
git-svn-id: svn://tug.org/texlive/trunk@18127 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty b/Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty new file mode 100644 index 00000000000..70238b56451 --- /dev/null +++ b/Master/texmf-dist/tex/latex/nolbreaks/nolbreaks.sty @@ -0,0 +1,68 @@ +% nolbreaks.sty by Donald Arseneau +% Public domain software -- please improve and submit to CTAN + +\ProvidesPackage{nolbreaks}[2002/09/19 \space v 1.0 \space + - no linebreaks in text] + +% Use \nolbreaks{some text} to prevent linebreaks in "some text". +% This has the advantage over \mbox{} that glue (rubber space) +% remains flexible. It has the disadvantage of not working in +% all cases! Most common cases are handled here (\linebreak is +% disabled, for example) but spaces hidden in macros or { } +% can still create break-points. +% +% Large pieces of text with no breaks can cause problems with +% paragraph justification. Giving the package option [ragged] +% allows a line before the unbreakable text to be cut short. +% +% You should declare \sloppy in your document. + +\let\nb@ragged\relax + +\DeclareOption{ragged}{ + \def\nb@ragged{% + \skip@\lastskip \unskip + \nb@counter \lastpenalty + \hskip \z@ plus 2cm\relax + \penalty\nb@counter + \advance\skip@ \z@ plus -2cm\relax + \hskip\skip@ + }} +\ProcessOptions + +\let\nb@@iwspace=\ % +\let\nb@@hskip=\hskip +\let\nb@@penalty=\penalty +\newcount\nb@counter +\ifx\langwohyphens\undefined + \newlanguage\nb@lang +\else + \let\nb@lang\langwohyphens +\fi + +\DeclareRobustCommand{\nolbreaks}[1]{% + \leavevmode + \begingroup + % Apply flexible lead-in + \nb@ragged + % Prevent hyphenation + \language\nb@lang + % Disable commands that give breakpoints + \let\ \nb@iwspace + \let\hskip\nb@hskip + \let\penalty\nb@penalty + \let\language\nb@counter + % Prevent breaks in math + \relpenalty\@M + \binoppenalty\@M + % Prevent breaks at spaces (only outermost visible spaces) + \@PreserveSpaces \@empty #1 \@PreserveSpaces + \endgroup +} + +\def\@PreserveSpaces#1 {#1\@ifnextchar\@PreserveSpaces{\@gobble}% + {\@firstofone{\nb@@penalty\@M} \@PreserveSpaces\@empty}} + +\def\nb@iwspace{\nb@@penalty\@M \nb@@iwspace} +\def\nb@hskip {\nb@@penalty\@M \nb@@hskip} +\def\nb@penalty{\nb@@penalty\@M \nb@counter} |