# How to reference something in superscript?

When I reference some label with \ref{label} I find the reference a little too big (Because it's the same size as everything else) I'd like them to be in superscript. But not everywhere. I want this behavior when I mention a figure/section. An alternative command would be preferable.

Example:

picture of a dinosaur - fig. 1.

Dinosaurs1 do move in herds

• You want see section \ref{sec:foo} to produce "see section ² " won't that look rather strange? – David Carlisle May 10 at 19:02
• That really would look strange. Maybe I chose my words poorly. The use case is not worded like this, the referencing itself is not part of the sentence, it's more like a citation. Like, when I mention something shown in a figure and I just want to have a reference there, in superscript. Is that a bad-practice? – Győri Sándor May 10 at 19:23
• Please edit your posting, including its title, to focus on what you really wish to achieve. Please be as clear as you can, and give as many relevant examples as you can think of. – Mico May 10 at 19:32
• but you are asking to globally change the way \ref works, which would have the effect I show. superscripts, whether for footnotes or citation usually have no preceding space, so it is hard to guess how you see this working it would help if you made a small complete (one page) document and you showed examples of the expected input and output. (\let\oldref=\ref \def\ref#1{\textsuperscript{\oldref{#1}} does what you ask but I can't believe that is really what you want. – David Carlisle May 10 at 19:49
• @GyőriSándor: Wouldn't this style of referencing be confusing for ther reader? What happens if you have a figure 1, a table 1 and a chapter1/section 1? How does the reader know to which of them the superscript number refers to? What about footnotes and citations (if a numeric citation style is used)? – leandriis May 10 at 20:25

## 1 Answer

I suggest you load the cleveref package (and, optionally, the hyperref package) and proceed by issuing \crefformat instructions to inform LaTeX that cross-references to figure and table environments created with \cref should be typeset in superscript-numeric format.

With this setup, you can still use the ordinary \ref command to create non-superscript cross-references.

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\crefformat{figure}{\textsuperscript{#2#1#3}}
\crefformat{table}{\textsuperscript{#2#1#3}}

\begin{document}
\begin{figure}\caption{Dinosaurs}\label{fig:din}\end{figure}
\begin{table} \caption{Numbers}  \label{tab:num}\end{table}
Dinosaurs\cref{fig:din} \dots

Numbers\cref{tab:num} \dots
\end{document}

• Thank you! Cleveref fits my needs exactly! – Győri Sándor May 13 at 22:27