0

How to use package setspace whit package hyperref. because I've been getting the following error below when I try to generate the tex file described in my MWE:

! Missing \endgroup inserted. \endgroup l.5 ...google.com}{\begin{spacing}{2} \end{spacing}} };

Here my MWE:

\documentclass{article}
\usepackage{hyperref,setspace,tikz}
\begin{document}
\begin{tikzpicture}
\draw node {\href{https://google.com}{\begin{spacing}{2} \end{spacing}}}; 
\end{tikzpicture}
\end{document}

Re-written like this, there are no problems:

\documentclass{article}
\usepackage{hyperref,setspace,tikz}
\begin{document}
    \href{https://google.com}{\begin{spacing}{2} Line1 \linebreak Line2 \end{spacing}}
\end{document}

But I got the same error rewriting like this:

\documentclass{article}
\usepackage{hyperref,setspace,tikz}
\begin{document}
\begin{tikzpicture}
    \href{https://google.com}{\begin{spacing}{2} Line1 \linebreak Line2 \end{spacing}}
\end{tikzpicture}
\end{document}

Note: I've already tried using the align = center key advised by @marmot when answering an earlier question of my own. See:I could not use spacing inside the node

  • 2
    The first thing one may try out before putting something in a node is whether it works outside of a node. Just putting \href{https://google.com}{\begin{spacing}{2} \end{spacing}} produces ! pdfTeX error (ext1): \pdfendlink cannot be used in vertical mode. \close@pdflink ...\Hy@VerboseLinkStop \pdfendlink l.4 ...ogle.com}{\begin{spacing}{2} \end{spacing}} so I suggest you first try to invent something that works outside TikZ before trying to embed it in a node. – marmot Mar 24 at 19:35
  • Hi @marmot, I rewrote the tex file and generated the pdf without problems, thus (without the preamble): \ begin {document} \ href {google.com} {\ begin {spacing} {2} Line1 \ linebreak Line2 \ end {spacing}} \ end {document}. But I got the same error rewriting like this (without the preamble): \ begin {tikzpicture} \ href {google.com} {\ begin {spacing} {2} Line1 \ linebreak Line2 \ end {spacing}} \ end {tikzpicture}. – Diego Bnei Noah Mar 24 at 19:53
  • 1
    I cannot compile the document you refer to as working with pdflatex, but xelatex works. And with xelatex also \documentclass{article} \usepackage{hyperref,setspace,tikz} \begin{document} \begin{tikzpicture} \draw node[text width=4cm] {\href{https://google.com}{\begin{spacing}{2} Line1 \linebreak Line2 \end{spacing}}}; \end{tikzpicture} \end{document} works, so I can put it into a node. – marmot Mar 24 at 20:26
0

As @marmot verified and following your guidelines I changed engine. I am using the command: latexmk -pdflua -pvc file.tex and really, with xelatex worked, i used latexmk -pvc -pdfxe, thanks for the warning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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