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.

For some reason I get a linebreak when using my \textlabel command in the table cell. It seems to work fine for everything else.

\usepackage[pdftex,bookmarks=true,bookmarksnumbered,colorlinks=true]{hyperref} % http://ctan.org/pkg/hyperref


        \edef\@currentlabel{#1}% Set target label
        \phantomsection% Correct hyper reference link
        #1\label{#2}% Print and store label

    \textbf{Col 1} & \textbf{Col 2} \\ \hline
    Bla1 & \textlabel{Blubb1}{reference1} \\
    & Description1 \\ 
    Bla2 & \textlabel{Blubb2}{reference2} \\
    & Description2 \\ \hline
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Avoid doing things in vertical mode, especially at the start of table cells.

        \edef\@currentlabel{#1}% Set target label
        \leavevmode\phantomsection% Correct hyper reference link
        #1\label{#2}% Print and store label
share|improve this answer
Excuse me, but could you elaborate a little further? What exactly does 'vertical mode' mean? I have to admit that I haven't written the command by myself, therefore don't really know how it works, however, am very eager to learn. –  cherrung Jun 9 '12 at 21:14
(very simple and somehow incorrect explanation) At the beginning of a cell, LaTeX is in "vertical" mode, which means that things "tend to be put atop each other", which makes \phantomsection occupy its own line, even though it does not print anything. By \leavevmode you "leave vertical mode" and enter "horizontal mode", where things are put next to each other and \phantomsection occupies zero horizontal space then. –  tohecz Jun 9 '12 at 21:25
I was away from machine but @tohecz gives a good explanation. Searching for "mode" on this site or other tutorials will give other examples of this distinction. –  David Carlisle Jun 9 '12 at 21:59
add comment

Your Answer


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.