My question is in the title of this post, but extends to other referencing commands like \eqref
, \citep
, \citet
(and the like) as well.
-
2I'd say this is somehow a duplicate of Good practice on spacing; it's a subcase of that question, even though this is not obvious from the question. – Hendrik Vogt Jan 25 '11 at 7:56
The ~
is a non-breaking space, (not really a symbol) so when you write in your text Table~\ref{mytable}
it ensures that the Table
part is kept together with the number. This is generally considered to be good for readability.
So that you don't forget, it's often helpful to make macros for references like these:
\newcommand*{\tabref}[1]{\tablename~\ref{#1}}
\newcommand*{\figref}[1]{\figurename~\ref{#1}}
Then you use \tabref{mytable}
and \figref{myfig}
in your text.
The refstyle
package provides a generalised interface to automatically construct macros like those above.
The cleveref
package with its \cref
command is even more powerful, since it figures out what type of object your reference refers to and generates the correct text automatically (so you don't need different \ref
commands for different reference types.)
If you are independently using the hyperref
package, it also provides an \autoref
command that works like cleveref
's \cref
command (and also makes the hyperlink target larger.)
-
4I recommend refstyle or cleveref for handling referencing macros. (As an extention to your macros.) Makes life much easier, I think. – Will Robertson Jan 24 '11 at 21:18
-
4
-
@Will (and Jake) Thanks for the suggestions about refstyle and cleveref; I've updated my answer. – Alan Munn Jan 24 '11 at 21:25
-
2
-
1While ~\cite() makes sense in numeric mode (where citations are "[2]") does it make sense with longer citations? I use it for both in case I ever switch, which seems like a bad thing. Thoughts? – TomOnTime Apr 22 '16 at 10:10
The ~
is called a tie because it ties two words together like in Section~\ref{sec:intro}
. The tie causes TeX never to break a line at a tie. Hence, Section
and the reference will end up together on the same line, making them easy to read. Tying together what belongs together is good practice and is not limited to \ref
. Another good use is tying an academic title to a name.
-
2or 75~kg for example – user2478 Jan 24 '11 at 21:31
-
It is good for salutations like Dr. Mr. etc and also suffixes to name like sr. Jr. I II III etc. – Aku Jan 25 '11 at 17:48
-
1should be typeset as
Dr.\,Hyronymous~Bosch
– user2478 Jan 25 '11 at 17:59 -
@Herbert I think a
` after the dot is better (unless you're using
\frenchspacing, but still...); the thin space is too small. Also I don't understand why Hyronymous (Hieronymus really) and Bosch should be tied.
H*` is the first name andBosch
the surname, which shouldn't be tied (Otherwise you might as well tieGeorge
andBush
and I don't want any ties with them.) – user10274 Feb 28 '12 at 18:25 -
@Herbert: While many of Knuth's ideas were "good", not all are practiced in the typesetting world outside of the TeX universe. Here are a few of examples: While people never line-break between numbers and units, there is no obvious prohibition against linebreaks between first and middle name or middle name and last name (judging from general practice).
\frenchspacing
has been the norm in the US (and elsewhere even more so) outside of a typewriter context for many decades. Vertical line stretching is rarely done, if ever. But it certainly makes sense to use~
for figures and tables. – Lover of Structure Jun 13 '12 at 19:17