[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bibtex and buggy wrapping of long lines



Martin Michlmayr <tbm@cyrius.com> writes:

> * Richard Lewis <rtf@jabble.com> [2005-01-16 20:44]:

>> Apparently newer versions of hyperref include a \url command that
>> corrects this problem automatically
>> 
>> If not, the fix is to insert spaces in the argument to \url (url
>> ignores spaces by default, if there was an actual space in the URL
>> you;d encode it as `+'), for example
>> 
>> \url{http://news.netcraft.com/archives/2004/07/01/ july_2004_web_server_survey.html}
>
> Thanks, this workaround works.  Do you know if there are plans to fix
> this in url.sty, as was done in hyperref.ref?  (I don't like to use
> hyperref because of the way links are rendered in the text.)

I don't know of any plans, but hyperref actually adds to url.sty
rather than providing a new command.  The relevent part is
\hyper@normalise, and putting the following [taken more or less
directly from hyperref.dtx] in your document seems to work [but
probably renaming the commands defined would be sensible], but I've
not read/tested it especially well...

\usepackage{url}
\makeatletter
\begingroup
  \endlinechar=-1
  \catcode`\^^M\active
  \catcode`\%\active
  \gdef\hyper@normalise{
    \begingroup
    \catcode`\^^M\active
    \def^^M{ }
    \catcode`\%\active
    \let%\@percentchar
    \let\%\@percentchar
    \ifx\@safe@activestrue\@undefined\else\@safe@activestrue\fi
    \hyper@n@rmalise
  }
  \catcode`\#=6
  \gdef\hyper@n@rmalise#1#2{
    \edef\Hy@tempa{
      \endgroup
      \noexpand#1{\Hy@RemovePercentCr#2%^^M\@nil}
    }
    \Hy@tempa
  }
  \gdef\Hy@RemovePercentCr#1%^^M#2\@nil{
    #1
    \ifx\limits#2\limits
    \else
      \Hy@ReturnAfterFi{
        \Hy@RemovePercentCr #2\@nil
      }
    \fi
  }
\endgroup
\long\def\Hy@ReturnAfterFi#1\fi{\fi#1}
\let\HyOrg@url\url
\DeclareRobustCommand*{\url}{\hyper@normalise\HyOrg@url}
\makeatother



Reply to: