# named href in tabularx with very long url

I just started to use TEX for automatic generation of eye catching pdf's. So for the moment this is on a good way.

But I'am on a point now I can't resolve with by myself. So I decided to ask for help :)

The Task:

I have a tabularx table which should contain a href element. This works well if the link is a simple one like http://tex.stackexchange.com.

\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\textbf{some text} & \textbf{some text} & \textbf{some text} \\ \hline
some text* & some text & Für \href{http://tex.stackexchange.com}{link text} \\ \hline
some text & some text & Umsetzung der \href{http://tex.stackexchange.com}{link text} \\ \hline
some text & some text & some text \\ \hline
\textbf{some text} & \textbf{some text} & \\ \hline
\end{tabularx}
\end{table}


This small example works well and creates a fine looking document.

But the url I want to hide behind the link text is a lot more complex. So the small example above is updated by the complex url and the document generation fails...

\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\textbf{some text} & \textbf{some text} & \textbf{some text} \\ \hline
some text* & some text & Für \href{http://www.xyz.com/bla/bla/blablabla/issues?set_filter=1&f[]=status_id&op[status_id]=o&v[status_id][]=1&f[]=category_id&op[category_id]=%3D&v[category_id][]=6&f[]=&c[]=tracker&c[]=status&c[]=priority&c[]=subject&c[]=assigned_to&c[]=updated_on&c[]=due_date&c[]=done_ratio}{link text} \\ \hline
some text & some text & Umsetzung der \href{http://www.xyz.com/bla/bla/blablabla/issues?set_filter=1&f[]=status_id&op[status_id]=o&v[status_id][]=1&f[]=category_id&op[category_id]=%3D&v[category_id][]=6&f[]=&c[]=tracker&c[]=status&c[]=priority&c[]=subject&c[]=assigned_to&c[]=updated_on&c[]=due_date&c[]=done_ratio}{link text} \\ \hline
some text & some text & some text \\ \hline
\textbf{some text} & \textbf{some text} & \\ \hline
\end{tabularx}
\end{table}


The error which was thrown is:

Runaway argument?
{|X|X|X|} \hline \textbf {Phase} & \textbf {Geplant (PT)} & \textbf {\ETC.
! File ended while scanning use of \TX@get@body.
<inserted text>
\par
l.49    \input{document.tex}


I'am pretty sure that this is caused by the special characters inside the url. So I was trying to escape the ampersand's and the square brackets. But this didn't help. The error is still the same.

Does anybody has a hint for me what would solve this?

Regards Kalle

## 1 Answer

There are two problems:

• \href contains %3D. Since tabularx scans the table contents as argument, the catcode of \href are not yet in force and % acts as comment char.
• & has a special meaning in tables.

Both characters can be protected in \href by using \% and \& instead of % and &:

\documentclass{article}
\usepackage{tabularx}
\usepackage[colorlinks]{hyperref}

\begin{document}
\centering
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\textbf{some text} & \textbf{some text} & \textbf{some text} \\ \hline
some text* & some text & Für
\href{http://www.xyz.com/bla/bla/blablabla/issues?set_filter=1\&f[]=status_id\&op[status_id]=o\&v[status_id][]=1\&f[]=category_id\&op[category_id]=\%3D\&v[category_id][]=6\&f[]=\&c[]=tracker\&c[]=status\&c[]=priority\&c[]=subject\&c[]=assigned_to\&c[]=updated_on\&c[]=due_date\&c[]=done_ratio}{link text} \\ \hline
some text & some text & Umsetzung der
\href{http://www.xyz.com/bla/bla/blablabla/issues?set_filter=1\&f[]=status_id\&op[status_id]=o\&v[status_id][]=1\&f[]=category_id\&op[category_id]=\%3D\&v[category_id][]=6\&f[]=\&c[]=tracker\&c[]=status\&c[]=priority\&c[]=subject\&c[]=assigned_to\&c[]=updated_on\&c[]=due_date\&c[]=done_ratio}{link text} \\ \hline
some text & some text & some text \\ \hline
\textbf{some text} & \textbf{some text} & \\ \hline
\end{tabularx}
\end{document}


• really thank you for that. I was staring at this for hours ... But was fixed on the ampersands and the square brackets :) totally missed that there was an percent character too. – Kalle Aug 17 '15 at 12:00