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'm using the varioref package to get descriptive references. When used with the hyperref package, the links will often go outside of the text boundary, as demonstrated in the MWE below.

If I set breaklinks=true in the hyperref package, then the link will break across lines (good), but at the expense of the link not working (bad).

Is there a way to fix this? In the context of this example, I would almost prefer, 'on the preceding page', to be regular text, and not part of the link.

\documentclass{report}
\usepackage[left=6cm,right=1cm,showframe=true]{geometry}               
\usepackage{varioref}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}
\usepackage[all]{hypcap}

\begin{document}

\begin{table}
 \centering
 \begin{tabular}{cc}
  1 & 2
 \end{tabular}
 \caption{We're going to link to this table}
 \label{tab:mytable}
\end{table}

\clearpage

Some text to fill in the space. This should emulate the problem- in Table \vref{tab:mytable}

\end{document}

EDIT Here's the relevant info from listfiles

varioref.sty    2011/07/27 v1.4z package for extended references (FMi)
hyperref.sty    2011/08/19 v6.82h Hypertext links for LaTeX

Following the comments, yes I'm using the latex->dvips->pstopdf route.

share|improve this question
    
Your example works fine for me (line break within "on the preceding page", correct link to the top of the table). –  lockstep Sep 4 '11 at 15:33
    
Using your MWE, the text doesn't go into the margin for me. "preceding" is the last word on the line, then "page" on the next line. If I add some more letters, it will break the line before "preceding", still nothing going outside the text boundary. I'm using an updated version of TeXlive 2011. (Edit: Damn, too late.) –  Torbjørn T. Sep 4 '11 at 15:35
    
Same here. What versions of hyperref and varioref are you using? To find out, add \listfiles before \documentclass{report} and check the .log file after you've compiled. –  Werner Sep 4 '11 at 15:35
    
I've posted my output here; I'm using TeXlive 2011, and necessarily have to use latex->dvips->pstopdf as the actual document uses pstricks –  cmhughes Sep 4 '11 at 15:48
    
With \usepackage[colorlinks=true,linkcolor=blue,breaklinks]{hyperref} the typesetting is correct. There are various ways to use pstricks with pdflatex. –  egreg Sep 4 '11 at 15:51
show 1 more comment

1 Answer

up vote 5 down vote accepted

You are probably typesetting with the latex+dvips+ps2pdf cycle; either use pdflatex or add the breaklinks options for hyperref.

\usepackage[colorlinks=true,linkcolor=blue,breaklinks]{hyperref}
share|improve this answer
    
You're correct. I can't use pdflatex as the actual document uses pstricks- I've updated the question too. –  cmhughes Sep 4 '11 at 15:49
2  
See question 8413:how-to-use-pstricks-in-pdflatex for using PSTricks with pdflatex. –  mas Sep 4 '11 at 15:57
    
Just for interest, I've since found that loading the cleveref package stops the description ('on the preceding page') from being a hyperlink, and works in the dvips->ps2pdf routine. –  cmhughes Sep 4 '11 at 19:33
    
I use pdflatex (three iterations). breaklinks breaks links in both ways. –  Raphael Nov 3 '11 at 17:43
    
@Raphael The breaklinks package does nothing with pdflatex. –  egreg Nov 3 '11 at 20:54
show 2 more comments

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.