Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am preparing my thesis and in many places I find the Overfull/Underfull warnings. Usually it is not very alarmingly visible in the document but sometimes it is painfully out of the specified margins. The MWE below exhibits one such instance:

    \documentclass[12pt]{report}
    \usepackage[margin=1.25in]{geometry}
    \usepackage{hanging}
    \usepackage{doi}

    \begin{document}

    \begin{hangparas}{.3in}{1}
    Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doi{10.1016/j.aap.2005.12.006}
    \end{hangparas}

    \end{document}

The end product is this: enter image description here

As can be seen the text overflows over the margin. How can I fix this? Is there a package or a command that can be used here to make the text "justified".

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Somehow the doi in unbreakable.

That's why you have to help LaTeX (which justifies per default) out here. It doesn't but the whole “word” doi:10.1016/j.aap.2005.12.006 into a new line because it would produce an even worse underful paragraph.

My proposals:

  1. Mimic the behaviour of url (macro: \doiurl{…})

    doi:{\urlstyle{same}\href{http://dx.doi.org/10.1016/j.aap.2005.12.006}{\nolinkurl{10.1016/j.aap.2005.12.006}}}
    
  2. doi: {\urlstyle… for comparison (macro: \doiurl[ ]{…})
  3. Make use of \sloppy (which kind of produce the above mentioned “underfull paragraph”)
  4. Insert a manual line-break (\\)

    \\\doi{10.1016/j.aap.2005.12.006}
    

Note that the differences between (3) and (4) are not in the last line!

Code

\documentclass[12pt]{report}
\usepackage[margin=1.25in]{geometry}
\usepackage{hanging}
\usepackage{url,doi}
\newcommand{\doiurl}[2][]{doi:#1{\urlstyle{same}\href{http://dx.doi.org/#2}{\nolinkurl{#2}}}}

\begin{document}
\begin{hangparas}{.3in}{1}
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doiurl{10.1016/j.aap.2005.12.006}
\end{hangparas}
\begin{hangparas}{.3in}{1}
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doiurl[ ]{10.1016/j.aap.2005.12.006}
\end{hangparas}
\begin{hangparas}{.3in}{1}\sloppy
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doi{10.1016/j.aap.2005.12.006}
\end{hangparas}
\begin{hangparas}{.3in}{1}
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625.\\\doi{10.1016/j.aap.2005.12.006}
\end{hangparas}

\begin{hangparas}{.3in}{1}
Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doiurl{10.4236/ib.2009.12012}
\end{hangparas}
\begin{hangparas}{.3in}{1}
Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doiurl[ ]{10.4236/ib.2009.12012}
\end{hangparas}
\begin{hangparas}{.3in}{1} \sloppy
Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doi{10.4236/ib.2009.12012}
\end{hangparas}
\begin{hangparas}{.3in}{1}
Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2).\\\doi{10.4236/ib.2009.12012}
\end{hangparas}
\end{document}

Output

Output

share|improve this answer
    
Or simply use the uri package instead of doi. ;-) –  Harish Kumar Nov 12 '12 at 1:48
add comment

Somehow the doi is unbreakable. you can adjust the hang dimension.

\usepackage[margin=1.25in]{geometry}
\usepackage{hanging}
\usepackage{doi}

\begin{document}
\begin{hangparas}{.45in}{1}
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doi{10.1016/j.aap.2005.12.006}
\end{hangparas}
\end{document}

enter image description here

You can use uri package instead of doi.

\documentclass[12pt]{report}
\usepackage[margin=1.25in]{geometry}
\usepackage{hanging}
\usepackage{hyperref,uri}

\begin{document}

\begin{hangparas}{.3in}{1}
Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doi{10.1016/j.aap.2005.12.006}
\end{hangparas}

\begin{hangparas}{.3in}{1}
 Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doi{10.4236/ib.2009.12012}
 \end{hangparas}

\end{document}

enter image description here

share|improve this answer
1  
A really nice quick fix - but this does not fully address the concerns here. Take for instance another reference: Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doi{10.4236/ib.2009.12012} Still falls out of margins. Any other ideas? –  RazorXsr Nov 12 '12 at 1:21
    
@RazorXsr: Use uri helps here as in the update. –  Harish Kumar Nov 12 '12 at 1:52
add comment

You can redefine \doi to allow a break before it with \allowbreak. Furthermore, if the break occurs there, fill the remaining (if any) space on the line with blanck space, so that no underfull nor overfull box will happen. Simply add this line

\expandafter\def\expandafter\doi\expandafter{\expandafter\hfil\expandafter\allowbreak\doi}

That is, the MWE becomes:

\documentclass[12pt]{report}
\usepackage[margin=1.25in]{geometry}
\usepackage{hanging}
\usepackage{doi}

\expandafter\def\expandafter\doi\expandafter{\expandafter\hfil\expandafter\allowbreak\doi}

\begin{document}

\begin{hangparas}{.3in}{1}
    Aguero-Valverde, J., \& Jovanis, P. P. (2006). Spatial analysis of fatal
    and injury crashes in Pennsylvania. \textit{Accident Analysis \& Prevention, 38}(3), 618-625. \doi{10.1016/j.aap.2005.12.006}
\end{hangparas}
\begin{hangparas}{.3in}{1}
Buck, A. J., Blackstone, E. A., \& Hakim, S. (2009). A multivariate Poisson model of consumer choice in a multi-airport region. \textit{iBusiness, 1}(2). \doi{10.4236/ib.2009.12012}
\end{hangparas}

\end{document}
share|improve this answer
    
Instead of \hfil\break a simple \linebreak[3] is more in the spirit of LaTeX and might also help. –  Martin Schröder Nov 12 '12 at 12:37
    
@Martin: Ok, but I think the one-line redefinition of \doi is more efficient because you don't need to edit all entries manually. –  Mafra Nov 12 '12 at 12:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.