0
\renewcommand{\figurename}{Paint }
\begin{figure}[h]
    \includegraphics{22.png}
    \label{fig:22}
\end{figure}

This is example reference \autoref{fig:22}

It write

This is example reference Figure 1

instead

This is example reference Paint 1.

What should I do to get Paint 1?

  • 2
    As always on this site, plesae provide a full (but minimal) example instead of a sniplet like this. Since \ref normally does not give any Figure prefix, you have something in your document you're not showing us. – daleif Jul 29 '20 at 12:45
  • I'm sorry, it's \autoref – Churkin Aleksey Jul 29 '20 at 12:47
  • 2
    Again, update your question, not everyone know where \autoref is coming from. It is a lot easier to help if one can just copy the code and try it as is. For example, use \rule{5cm}{5cm} instead of your image, then that requirement in the example is gone too.\ – daleif Jul 29 '20 at 12:55
  • it's enough code to see problem. I'd like to see "Paint 1", instead default "1" or "Figure 1" – Churkin Aleksey Jul 29 '20 at 13:02
  • If you don't use the babel package then \renewcommand{\figureautorefname}{Paint} works. If you do use babel then you need \addtoextrasnameofyourlanguage{\renewcommand{\figureautorefname}{Paint}} as explained in for example https://tex.stackexchange.com/questions/186946/changing-the-autoref-name-for-chapter. You didn't provide a full example so it's hard to tell which of the two you need, or maybe even another option depending on your setup. Note that you should not put a space character after Paint because there is already a space inserted automatically. – Marijn Jul 29 '20 at 13:35
  • Actually I'd say it is very selfish to not provide code others can test without adding a lot of stuff. Potentially their solution might then be wrong because you're using some package you never mentioned. – daleif Jul 29 '20 at 15:28

2 Answers2

0

Just create a new environment for paintings.

It would just be easier to create your own new environment than tinkering with figure. Combining the solutions from here and here you can easily create a new environment for paintings that behaves just like figures would, but built for purpose:

Output

enter image description here

MWE

\documentclass[10pt,a4paper]{article}
\usepackage{newfloat}
\usepackage{hyperref}
\usepackage{cleveref}

\DeclareFloatingEnvironment[ fileext=lop, listname={List of Paintings}, name=Painting, placement=tbhp, within=section, ]{painting}

\crefname{painting}{painting}{paintings} \Crefname{painting}{Painting}{Paintings}

\begin{document} \begin{painting} \centering Some painting should go here. \caption{Something about the painting.} \label{painting} \end{painting}

You could use \texttt{autoref} to reference \autoref{painting}, but likely \texttt{cref} would be better to refer to \cref{painting} as either \Cref{painting} or \cref{painting}. \end{document}

oliversm
  • 2,717
0

If all your figure environment should be labeled “Paint” (but you should check the grammar), you can do it with hyperref only.

However you need the caption, or the \label will refer to something random.

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}

\renewcommand{\figurename}{Paint} % is it right? \renewcommand{\figureautorefname}{Paint}

\begin{document}

\begin{figure}[htp] \centering

\includegraphics[width=2cm]{example-image}

\caption{A caption}\label{fig:22} \end{figure}

This is example reference \autoref{fig:22}

\end{document}

enter image description here

With cleveref:

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}

\renewcommand{\figurename}{Paint} % is it right? \crefname{figure}{Paint}{Paints}

\begin{document}

\begin{figure}[htp] \centering

\includegraphics[width=2cm]{example-image}

\caption{A caption}\label{fig:22} \end{figure}

This is example reference \cref{fig:22}

\end{document}

egreg
  • 1,121,712