1

I use the hyperref package and the corresponding \href{}{} command and would like to adjust the box which is drawn around the text. In more detail, in the picture below you can see a link for address, phone number, and email. The boxes around phone number and email are ok. However, looking at the box for the address one can see that there is a line break and actually there are two boxes and the bottom border of the lower box is acutally crossing the box of the phone number.

enter image description here

I am aiming for only one box around the address which does not cross the lower box. For illustration see the following image

enter image description here

or even borders whith some space in between.

When opening the template in overleaf and replacing \cvaddress{United Kingdom}%address with \cvaddress{\href{https://osm.org/go/euut1kjnX?m=}{United Kingdom, this is just for a linebreak}}%address

one immediately encompasses the problem I am trying to solve, as can be seen here

enter image description here

To replicate the problem one can use the following code

\documentclass[10pt,a4paper]{article}

\usepackage[]{hyperref}
%\usepackage[]{hyperref}

\begin{document}
    
\begin{tabular}{p{4cm}} \href{https://osm.org/go/euut1kjnX?m=}{United Kingdom, this is just for a linebreak} \end{tabular}

\end{document}

Of course, just expanding the tabular width is not an option ;)

In more detail, I use the following documentclass \documentclass[letterpaper]{twentysecondcv} and inserted the following line \RequirePackage[allbordercolors=red, pdfborder = 0 0 0]{hyperref} in twentysecondcv.clsfile. The source code can be found here. Of course, I adapted the source code somehow to obtain a different style, but this does not impact the problem I am facing, as it is present in the source code as well.

If anything is unclear please let me know immediately and I am going to try my best to solve it as soon as possible!

EDIT: I added a MWE and restructured the question slightly.

4
  • 1
    Welcome to TeX.SE! Please show us a short compilable TeX code resulting in your issue. Then we do not have to guess what you have done ...
    – Mensch
    Commented Nov 30, 2023 at 18:58
  • Thank you for your remark. Unfortunately, I am not sure how to show the code as a MWE directly here due to the fact that the linked template I use does include a .cls file. Usually, I would show the complete LaTeX code where everything is in one document, but I am not familiar in the case of the main file accessing the .cls file. Could you give me a hint how to share the code in this case? Actually, this is the reason why I linked everything (source code and compileable template) and exactly what code to replace.
    – m0byn
    Commented Nov 30, 2023 at 21:40
  • A link to the class file and a basic document is often helpful, a full template over link may have some excess content and can be a few more clicks to get the base document to run locally. I'm guessing in this case you could use article class and reproduce the issue with something like \begin{tabular}{p{4cm}} \href{https://osm.org/go/euut1kjnX?m=}{United Kingdom, this is just for a linebreak} \end{tabular}
    – Dai Bowen
    Commented Nov 30, 2023 at 21:59
  • Thank you very much!! This is very helpful and I am going to include this MWE in my question right away!
    – m0byn
    Commented Dec 1, 2023 at 8:59

3 Answers 3

0

If you want a single link margin you must put the text in its own box:

\documentclass[10pt,a4paper]{article}

\usepackage[]{hyperref}

\begin{document}
    
\begin{tabular}{p{4cm}} \href{https://osm.org/go/euut1kjnX?m=}{\parbox[t]{4cm}{United Kingdom, this is just for a linebreak}} \end{tabular}

\end{document}

enter image description here

With lualatex it should be theoretically possible to calculate the link area and to use quadpoints to get a combined area, but I'm not aware of any implementation and also imho the support for quadpoints in pdf viewers is rather sketchy.

1
  • The solution can be so simple! Thank you very much!
    – m0byn
    Commented Dec 1, 2023 at 13:30
0

It might be easier to use the [colorlinks=true] option in the hyperref package. This will give a link without the box. It is perhaps more elegant.

\documentclass[10pt,a4paper]{article}

\usepackage[colorlinks=true]{hyperref}
%\usepackage[]{hyperref}

\begin{document}
    
    
    
    \href{URl}{A general URL \newline on multiple lines that \newline goes nowhere}
    
    Text\cite{Citation} 
    More text\footnote{Footnote}
    
    Details of colour options for links are in section 5.6 of the \href{https://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/contrib/hyperref/doc/hyperref-doc.html#x1-180005.6}{package \newline
         help.} 

\begin{thebibliography}{9}

    \bibitem{Citation}Cited paper

\end{thebibliography}

\end{document}

(I could not find your source-code easily.)

1
  • This is not an answer in my opinion, as I explicitly ask for the box. I am aware of the possibility to remove the borders. However, the boxes shall draw attention that there is a something/a link when opening the file electronically.
    – m0byn
    Commented Dec 1, 2023 at 9:05
0

With pdflatex, you can use \pdflinkmargin (the experimental pdflinkmargin option seems broken):

\documentclass[10pt,a4paper]{article}

\usepackage{hyperref}
\pdflinkmargin0.3pt
\begin{document}

\begin{tabular}{p{4cm}} \href{https://osm.org/go/euut1kjnX?m=}{United Kingdom, this is just for a linebreak} \end{tabular}

\end{document}

But there is always two links (and two boxes) !

You must log in to answer this question.

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