9

Could someone help to correct the warning I get related to an underfull box with the following code? I have tried \hfill, hspace*{\hfill} etc with no luck.

\documentclass[twocolumn,draft]{svjour3}
\usepackage{lmodern}
\usepackage{url} 

\usepackage[breaklinks]{hyperref} %make hyperlinks references
    \hypersetup{colorlinks=true,linkcolor=blue,          % color of internal links
        citecolor=blue,linktocpage=true}
\usepackage{breakurl}


\begin{document}

\title{Something}

Microsoft continued to gain market \footnote{\url{www.some-asd-sdsasdasd-asdas-dasdas-dasdas-asd.com}}

\end{document}

So the answer to this is to use: the following: \usepackage{ragged2e}
\footnote{\RaggedRight\url{www.some-asd-sdsasdasd-asdas-dasdas-dasdas-asd.com}}

Credits to How can I make my text never go over the right margin by always hyphenating or breaking on word-boundaries?

Alex
  • 91
  • Man I gave up trying to fix those types of error/s a long time ago... – Nicholas Hamilton Dec 29 '12 at 20:32
  • 1
    Welcome to TeX.sx! Things like that require luck; it's nearly impossible to break correctly paragraphs with long URLs. Can you give a more realistic example? – egreg Dec 29 '12 at 21:10
  • Nope :). IMO this example expresses all I want. I have a long url in a footnote which breaks into multiple rows (in a two column class) and does not fill the box. – Alex Dec 30 '12 at 10:12
  • 1
    while it's possible to break a url, i think it may not be possible to get rid of the underfull box message. i worked on a project a long time ago that needed to break long words (not just urls) automatically. we got the breaks we needed (with proper hyphenation), but just learned to live with the underfull box messages. there were few enough that they could easily be checked. – barbara beeton Dec 30 '12 at 13:57

5 Answers5

8

As already stated, the command \raggedright should do the trick, whether you are using \url or another command.

No package is needed for this, as it is already a built in LaTeX command.

Microsoft continued to gain market \footnote{\raggedright\url{www.some-asd-sdsasdasd-asdas-dasdas-dasdas-asd.com}}
1

I took the following code snippet from another question:

\newcommand{\url}[1]{%
\begingroup
\ttfamily
 \begingroup\lccode`~=`/\lowercase{\endgroup\def~}{/\discretionary{}{}{}}%
 \begingroup\lccode`~=`.\lowercase{\endgroup\def~}{.\discretionary{}{}{}}%
 \catcode`/=\active\catcode`.=\active
 \scantokens{#1\noexpand}%
 \endgroup
}
alexkelbo
  • 837
0

You could use the \href{<my_url>}{<description>} command. You can add theurl as description so that the text can be broken up correctly. Example:

\documentclass[a4paper]{article}
\usepackage{hyperref}

\begin{document}

Data clustered into three groups \footnote{Source:\href{https://en.wikipedia.org/wiki/Cluster\_analysis\#/media/File:KMeans-Gaussian-data.svg}{https://en.wikipedia.org/wiki/Cluster\_analysis\#/media/File:KMeans-Gaussian-data.svg}}

\end{document}

Applying \href{}{} to a long url

n0n4m3
  • 21
0

Inserting an \hfill before the \url, i.e. \footnote{\hfill\url{...}}, removes the warning. The only drawback of this is that it pushes the first part of the URL to the right, so that you have some extra space between the footnote number and the URL.

Another idea ist to use \footnote{\rlap{\url{...}}}. This printes the URL but ignores its width completely. The URL will stick out to the second column then, though, if it is too long.

siracusa
  • 13,411
0

use

\footnote{\sloppy\url{www.some-asd-sdsasdasd-asdas-dasdas-dasdas-asd.com}}
  • I am sorry this does not work. – Alex Dec 30 '12 at 10:08
  • it works for me ... –  Dec 30 '12 at 10:09
  • Do you use \usepackage{lmodern}? because if I comment this,then yes it works...but then I have other warnings like:LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <4.25> not available – Alex Dec 30 '12 at 10:23
  • I run pdflatex without loading package breakurl which makes no sense –  Dec 30 '12 at 10:33
  • Sorry it doesn't seem to work for me. The only thing it works is to add the following code: \usepackage{etoolbox} \apptocmd{\sloppy} {\hbadness 10000\relax}{}{} taken from [1] with \sloppy. But should I do this in a journal. I do not think that this is acceptable.... [1]: http://tex.stackexchange.com/questions/10924/underfull-hbox-in-bibliography?rq=1 – Alex Dec 30 '12 at 11:00