[OS X TeX] A \url problem

Ross Moore ross at ics.mq.edu.au
Sun Nov 1 15:02:26 EST 2009

Hello Vic, and others.

On 02/11/2009, at 5:46 AM, Vic Norton wrote:

> On Nov 1, 2009, at 11:38 AM, Maarten Sneep wrote:
>> try to use \href{}{} instead. That way I don't think the url is  
>> broken, although text itself can be broken. Note that this is  
>> (breaking links across lines) is only supported with pdflatex, not  
>> tex+ghostscript.
> On Nov 1, 2009, at 11:46 AM, Claus Gerhardt wrote:
>> Try loading the hyperref package. The command below works fine for  
>> me. I am adding the files that are routinely loaded in my set up.
> Thanks for the advice, guys. Unfortunately nothing seems to work.

So what packages *are* you loading?
Is it just  url.sty  ?
Or something else as well, or instead.
Please show your complete LaTeX preamble, otherwise noone
can reproduce the problems you are describing.

> I've decided to go with
>   \begin{minipage}{6.0in}
>      \url{http://vic.norton.name/finance-math/notionportf/ 
> pricedistrib.csv}
>   \end{minipage}
> which doesn't split the URL and looks pretty good.
> I have noticed a curious behavior with
>   \begin{minipage}{5.0in}
>      \url{http://vic.norton.name/finance-math/notionportf/ 
> pricedistrib.csv}
>   \end{minipage}
> This typesets as
>    http://vic.norton.name/finance-math/notionportf/
>    pricedistrib.csv

Your original coding was quite problematic:

> \parbox{6.0in}{\url{
>   http://vic.norton.name/finance-math/notionportf/pricedistrib.csv
> }}

  since there are spurious spaces at the beginning and end:

  ' http://vic.norton.name/finance-math/notionportf/pricedistrib.csv '

This is one way to solve the problem:


but is rather ugly, and may not be sufficiently flexible; as this


might result in one or more of the % symbols becoming part of the URL.

A better way is to declare any long URLs within the document preamble.

\urldef ....  other URL definitions ...


Note that hyperref must be loaded *after* uses of \urldef...\url{....}
since it changes the definition of \url .

Now all of the following should work properly:




> When you put the cursor over the text in the first line, you are  
> pointing at
>    http://vic.norton.name/finance-math/notionportf/

Aaah, This is due to the extra space character at the beginning, which
acts as a separator.


This your  \baseurl  setting, right?

> but, when you move the cursor just to the right of the text, you  
> start pointing at the correct URL
>    http://vic.norton.name/finance-math/notionportf/pricedistrib.csv

This is what you want, but it occurs only after that initial space
has been included as part of a URL.

> Finally, when you put the cursor over the text in the second line,  
> you are again pointing at
>    http://vic.norton.name/finance-math/notionportf/pricedistrib.csv

You have to be very careful with using \url directly,
since it adjusts the \catcode of many characters.
But this cannot happen when the  {\url{....}} is within
the argument of other commands.
The inconsistency of results can be very confusing.
That's why it is better to make use of \urldef  ...

   ... or use Hyperref's  \href command
--- but this is also subject to difficulties when used
within the argument of other commands.

> Regards,
> Vic

Hope this helps,


Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114

More information about the MacOSX-TeX mailing list