Talk:LaTeX/Labels and Cross-referencing

Tilde before \ref ?
The "~" (tilde) does not seem to be explained when used as a prefix for "\ref", as in, "~\ref". Why is that? What is the tilde for? --169.234.25.104 (talk) 20:58, 1 October 2010 (UTC)


 * The "~" (tilde) makes a non-breaking space, so you don't end up with something like Table (newline) 2. Jevon (talk) 01:49, 25 November 2010 (UTC)

Label with Custom Text
I wanted to create a label with a custom text in one of my documents and I didn't find any good information on the net describing how to do it exactly, so I figured this out:

\newcommand{\customlabel}[2]{\newcommand{\@old@currentlabel}[0]{\@currentlabel}\renewcommand{\@currentlabel}[0]{#1}\phantomsection\label{#1}\renewcommand{\@currentlabel}[0]{\@old@current}}

It introduces a new command named \customlabel that takes 2 parameters: first the label name (just like \label does), the second parameter is the text that will later appear when you do a \ref to the label. E.g. if you put \label{foo,bar} in any place of a LaTeX file, you can refer to it by \ref{foo} and the text displayed as the link will be "bar".

I found it quite hard to figure out how to do it, but surprisingly easy to do once I did. I also think this might be usfull for quite a number of people. Since I really don't know how to edit this properly I hope somebody might be able to insert it on this page: But keep in mind I'm not proficient in writing latex macros, so showing this to somebody who is beforehand might be a good idea.

--129.13.72.197 (talk) 15:37, 8 April 2010 (UTC)

Changed the "append" in the \numberwithin{equation}{section} example to "prepend", because this is the case.

Limits/ requirements on Marker
Dear all,

I think it would be helpful to explain what type of characters are usable for the marker. It seems to me that prettyref does not like the underscore "_" character as part of a single marker.

Issues with links to tables and figures handled by hyperref
The behavior described in "Issues with links to tables and figures handled by hyperref" seems fixed. Can someone else test this on his setup with up-to-date version of the packages. I am using hyperref with the following options: "\usepackage[pdftex,hidelinks]{hyperref}".