Hot answers tagged urls
6
The break points set by package url can be configured by setting \UrlBreakPenalty and \UrlBigBreakPenalty. A value of 10000 prevents the hyphenation:
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{url}
\usepackage{apacite}
\usepackage[T1]{fontenc}
\usepackage[osf]{libertine}
\mathchardef\UrlBreakPenalty=10000
\mathchardef\UrlBigBreakPenalty=10000
...
4
Please always post a complete document not just a fragment.
If you add
\show\prefix
you will see it is not exactly the characters before : it is
> \prefix=\long macro:
->\StrBefore {a:b}{:}.
Which presumably does not expand to something hyperref likes.
This version just uses an expandable macro to split on :
\documentclass{article}
...
4
biblatex gives some small stretchability in URL breaking using url package \Urlmuskip parameter. This is there whether or not multicolumn is used, it's just that in the narrow measure of a multi column setting the stretchability is more likely to be used if available.
There is probably a higher level biblatex setting for this, but this just patches the ...
3
apacite uses \AtBeginDocument to switch to the APACtt URL style, but one may also switch to APACsame. See section 8.2 of the apacite manual for details.
\documentclass{article}
\usepackage{url}
\usepackage{apacite}
\AtBeginDocument{\urlstyle{APACsame}}
\begin{document}
\url{http://www.google.com}
\end{document}
3
In verbatim environments the - is made active in order to break ligatures, but \url, among its checks doesn't take care of this.
You can fix the behavior in this way:
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{hyperref}
\makeatletter
\let\ORIGhyper@normalise\hyper@normalise
\def\grigg@hyper@normalise{%
\begingroup\begingroup\lccode`\~=`\-
...
1
Here's one work-around:
\documentclass{article}
\usepackage{fancyvrb,hyperref}% http://ctan.org/pkg/{fancyvrb,hyperref}
\newcommand{\URL}[1]{\url{\detokenize{#1}}}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
\URL{http://a-z.example}
\end{Verbatim}
\end{document}
1
It's not clear why you want to split at the colon; however, this is a different way to cope with the problem.
\documentclass{article}
\usepackage{xparse,l3regex}
\usepackage{hyperref}
\ExplSyntaxOn
\tl_new:N \l_gecko_prefix_tl
\tl_new:N \l_gecko_postfix_tl
\NewDocumentCommand{\qname}{m}
{
\regex_match:nnTF { \: } { #1 }
{
\tl_set:Nn ...
Only top voted, non community-wiki answers of a minimum length are eligible