# Problem with making a "new float" and using \autoref{} command

I'm trying to do a new float called "grafico" with the float package. It works fine, but when I try to do a reference, i.e. \autoref{}, it only shows the float number (e.g. If it's "Gráfico 2.1: blah blah", It only shows "2.1" when I use \autoref{}, and I want it to say "Gráfico 2.1".

Here is my code:

\documentclass[11pt,a4paper,table]{report}
\usepackage[spanish,es-tabla,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}

\usepackage{float}
\newfloat{grafico}{thp}{lop}
\floatname{grafico}{Gráfico}
\renewcommand{\thegrafico}{\arabic{chapter}.\arabic{grafico}}
\renewcommand{\thegrafico}{\arabic{section}.\arabic{grafico}}

\usepackage[
urlcolor=blue]{hyperref}
.
.
\begin{document}
\selectlanguage{spanish}
.
.
some text here...
.
.
\begin{grafico}[!h]
\begin{center}
\includegraphics[width=1\textwidth]{riskplot.pdf}
\caption{Porcentaje de los riesgos por región.}
\label{graf:riskplot}
\end{center}
\end{grafico}
.
.
.
.
\end{document}


I'm using TexMaker on Windows 7. Can anybody help me? Thanks in advance!

• \autoref{..} is a command from the hyperref package. Your MWE doesn't include it. Try, if this is source of your problem. Nov 2, 2015 at 2:35
• @Zarko, I forgot to put it, sorry about that, I have a really long preamble.. thanks! (I already edited the question) Nov 2, 2015 at 2:40
• IYou need to define '\autoref' name ... see my answer. Nov 2, 2015 at 2:47
• @Zarko, can you be a little more specific please? I'm new at this, and I know I might need to edit the \autoref command, but the thing is how can I do it? I tried checking the package documentation but didn't got to solve the problem.. thanks! Nov 2, 2015 at 2:49

It seems, that hyperref package is not aware of new float name, so it is necessary to define it with:

\def\graficoautorefname{Gráfico}


Complete code (without Spanish babes, since I haven't it installed):

\documentclass[11pt,a4paper,table]{report}
%\usepackage[spanish,es-tabla,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{float}
\newfloat{grafico}{thp}{lop}
\floatname{grafico}{Gráfico}
\renewcommand{\thegrafico}{\arabic{chapter}.\arabic{grafico}}
\renewcommand{\thegrafico}{\arabic{section}.\arabic{grafico}}
\usepackage[
urlcolor=blue]{hyperref}

\begin{document}
%\selectlanguage{spanish}
some text here...
\begin{grafico}[!h]
\begin{center}
\includegraphics[width=0.5\textwidth]{example-image}
\caption{Porcentaje de los riesgos por región.}
\label{graf:riskplot}
\end{center}
\end{grafico}