2

I have looked at the first comment to this question on % in urls and found that I didn't need to type \ ahead of each %. However, in WinEdt 7.1, everything from the first % in the first URL is now greyed out and I do not know if this is why I am getting an error with the overfull \hbox when I compile to PDF.

The problem in LaTeX is

proposal P293 (see \url{http://www.foodstandards.govt.nz/code/proposals/documents/Reanalysis%20of%20Nutriti.pdf} and \url{http://www.foodstandards.govt.nz/code/proposals/documents/P293_SD3.pdf} for the full analysis reports of the experiments).

The auto linebreak for the second URL should be after /code and not after /proposals as /proposals is going past the right hand margin in my document.

How can I force the linebreak to occur in the correct place in the second URL and still have the link work correctly?

The start of my report class is

\documentclass[11pt,PhD]{muthesis}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm}
\usepackage{amsfonts}
\usepackage[a4paper,layout=a4paper,
        bindingoffset=4cm,left=0cm,right=2cm,
        head=2.5cm, bmargin=2cm]{geometry} 
\usepackage{microtype}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{url} 
\usepackage[round]{natbib}
\usepackage{listings}
\usepackage{booktabs} 
\usepackage{multirow} 
\RequirePackage[l2tabu, orthodox]{nag}
\usepackage{cleveref}

2 Answers 2

2

Use the hyperref package to improve the behavior of the \url command. Use it with hidelinks option to view black links. If you don't use \% (using the url or hyperrefpackages) all that happens is that WinEdt means a comment but nothing wrong happens to the output document.

Add the \sloppy command to solve the problem with overfull boxes.

\documentclass[11pt,PhD]{muthesis}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm}
\usepackage{amsfonts}
\usepackage[a4paper,layout=a4paper,
        bindingoffset=4cm,left=0cm,right=2cm,
        head=2.5cm, bmargin=2cm]{geometry}
\usepackage{microtype}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{multirow}
\RequirePackage[l2tabu, orthodox]{nag}
\usepackage{cleveref}
\usepackage[hidelinks]{hyperref}
\begin{document}
    \sloppy
    proposal P293 (see \url{http://www.foodstandards.govt.nz/code/proposals/documents/Reanalysis\%20of\%20Nutriti.pdf} and \url{http://www.foodstandards.govt.nz/code/proposals/documents/P293_SD3.pdf} for the full analysis reports of the experiments).
\end{document}

You can read what the sloppy command does.

4
  • The \sloppy command has stopped the behaviour in the paragraph. I tried to use the hyperref package as suggested but got the apparently common error `! Argument of \contentsline has an extra }.' and my dissertation no longer compiled. I haven't been able to locate the source of that problem in the .cls or elsewhere, so I have chosen not to use that extra package.
    – Michelle
    Nov 11, 2013 at 5:04
  • @Michelle If with the url package works well, then use it. I recommend hyperref only to have a hyperlink. However it is strange that this error occurs, there must be something in the document that causes it.
    – osjerick
    Nov 11, 2013 at 12:15
  • 2
    \sloppy affects the entire document. it's better to use \begin{sloppypar} ... \end{sloppypar} around just the paragraph or section that contains the problematic url to limit its effect. Nov 11, 2013 at 14:02
  • @barbarabeeton certainly is a better solution.
    – osjerick
    Nov 11, 2013 at 14:19
1

I would just reformulate the sentence;

\documentclass[11pt]{muthesis}

\usepackage[hidelinks]{hyperref}

\begin{document}

\noindent Proposal~P293 (where the documents for the full analysis reports of the experiments can be found at \url{http://www.foodstandards.govt.nz/code/proposals/documents/Reanalysis%20of%20Nutriti.pdf} and \url{http://www.foodstandards.govt.nz/code/proposals/documents/P293_SD3.pdf}).

\end{document}

output

If this is not an option, use the sloppypar environment as mentioned by barbara beeton in a comment to OSjerick's answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .