8

in this example, how can I customize \autoref. ie instead of printing table 1, it puts Tab.1 same question with Figure = Fig. and equation = Eq.

\documentclass{article}
\usepackage[T1]{fontenc}
%\usepackage[francais]{babel} 
\usepackage{graphicx}
\usepackage[font=footnotesize,labelfont={bf,sc,small},figurename=Fig.,tablename=Tab.]{caption}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref} 

\begin{document}

change the writing of \autoref{tab} to Tab.1

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
table & Tab. \\
\hline
figure & Fig. \\
\hline
equation & Eq. \\
\hline
\end{tabular}
\end{center}
\caption{Exemple d'environnement table}
\label{tab}
\end{table}

\end{document}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
simo
  • 303
  • 1
    Welcome to TeX.SE! Since your question is about the \autoref command provided by the hyperref package, I've removed the cleveref tag, added the hyperref tag, and removed the instruction \usepackage{cleveref}. If, however, the question is really meant to be about the cleveref package and its command \cref, please indicate that that's the case. – Mico Nov 06 '13 at 22:18

1 Answers1

10

Voila:

\documentclass{article}
\usepackage[T1]{fontenc}
%\usepackage[francais]{babel} 
\usepackage{graphicx}
\usepackage[font=footnotesize,labelfont={bf,sc,small},figurename=Fig.,tablename=Tab.]{caption}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref} 

\begin{document}

\renewcommand{\tableautorefname}{Tab.} % PS

change the writing of \autoref{tab} to Tab.1

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
table & Tab. \\
\hline
figure & Fig. \\
\hline
equation & Eq. \\
\hline
\end{tabular}
\end{center}
\caption{Exemple d'environnement table}
\label{tab}
\end{table}

\end{document}

One should change not the meaning of \somethingname but \somethingautorefname. In this case it is \tableautorefname.

enter image description here

  • exactly what I want .. thank you very much ... – simo Nov 07 '13 at 19:50
  • 4
    Note: crucial is to put the renewcommand ... statement after \begin{document} -- I was trying in the preamble and didn't work. – juanmirocks Apr 24 '17 at 14:33
  • 1
    nice catch @juanmirocks ! How did you discover it? Anyone can shed any insight as to why this only works after \begin{document} ? – Ciprian Tomoiagă Feb 06 '19 at 10:38
  • Would you know what is the equivalent of \tableauautorefname for enumerate? RE: https://tex.stackexchange.com/questions/564957/customize-the-name-of-autoref-for-a-list-item cc @simo @juanmirocks @cipriantomoiaga – Erwann Oct 02 '20 at 18:15