I need to reference several tables like Tables 1-3 or Tables 3.1 to 3.3 related with the section, I'm using the normal \ref{table1,table2,table3}
to do what I want, but when I compile I get something like ???
Could someone tell me how to solve this little problem?
1 Answer
As already suggested in one of the comments, to achieve your objective you should load the cleveref package and type
\cref{table1,table2,table3}
Assuming these tables are numbered 1, 2, and 3, respectively, and assuming you're writing in English, you'll get
Tables 1--3
where "--" is supposed to represent an en-dash. (The conjuction particle is actually configurable; if one states \newcommand{\crefrangeconjunction}{ to~}
in the preamble, one would get "Tables 1 to 3" instead of Tables 1--3
.)
Note that you needn't actually enter the labels in consecutive order; if you'd written \cref{table2,table3,table1}
, you'd still have gotten "Tables 1--3".
The package does impose an important restriction on the characters permitted in labels: since ,
is used as the separator between labels that form the the argument of \cref
, you can't use ,
as a component of a label.
-
2One can also use the
\crefrange{table1}{table3}
command to achieve a similar effect without having to type all of the objects between Sep 8, 2014 at 20:05 -
1@darthbith - The example I gave simply copied the setup given by the OP. For
\crefrange{table1}{table3}
to give the same result as\cref{table2,table3,table1}
, one would also have to assume that there are no other tables in the range given by the lowest and higesttable
number. This may or may not be a valid assumption, right?– MicoSep 8, 2014 at 20:14 -
Correct,
\crefrange
simply produces a consecutive range. Of course\cref
and\crefrange
do the same thing in this case, and in this case one can be more explicit (or save some typing for a very large range of objects) if it is wished :-) Sep 8, 2014 at 20:19
\documentclass{...}
and ending with\end{document}
. You might also want to add to your question how you're including the pdfs etc.cleveref
package for that: the\cref
command compresses and sorts references automatically. It even saves you typing the word ‘tables’ whatever your language (well, a number of languages).