4

When I am using \autoref{fig:lion} the the output look like this: Ábra 1 (this is a hungarian document and it means Figure 1). And when I am hovering over the reference text, the text (Ábra 1) shines yellow (I am using overleaf editor).

Is there a way to switch from Ábra 1 into 1. ábra, when I am referencing a figure, the whole reference text should shine yellow, when I am hovering over the reference text.

Sometimes the reference output should look like this: 1. ábrán, cuz sometimes we are using suffix after a word, so this case, the reference text should look like this 1. ábrán, and when I am hovering over the reference text, the text (1. ábrán) should shine yellow.

If I am using \ref{fig:lion} then the output looks like this 1, so I have to use \ref{fig:lion}. ábra or \ref{fig:lion}. ábrán, but when I am hovering over the text, only the number shines yellow. I want the whole reference text to shine yellow when I am hovering over the reference text.

I hope that makes sense.

The only solution is that I can think of is \hyperref[fig:lion]{1. ábra}, but I do not know how to build a custome figure ref counter.

By the way, in the document I am referencing a figure several time, sometimes in a different section.

Other thing is that, there are multiple suffixes in Hungarian language, 1. ábrán is just one of them.

UPDATE

\documentclass[12pt,a4paper]{report}

\usepackage{t1enc}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage[thmmarks,amsmath]{ntheorem}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{listingsutf8}
\usepackage{color}
%\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{anysize}
\usepackage[magyar]{babel}
\selectlanguage{magyar}
\usepackage{sectsty}
\usepackage{setspace}
\usepackage[hang]{caption}
\usepackage{hyperref}
\usepackage{float}
\usepackage[euler]{textgreek}
\usepackage{booktabs}

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\marginsize{2.5cm}{2.5cm}{1.0cm}{1.0cm} % anysize package

\hypersetup{
    bookmarks=true,        
    unicode=false,           
    pdftitle={...},       
    pdfauthor={...},   
    pdfsubject={...}, 
    pdfcreator={...},   
    pdfproducer={Producer},   
    pdfkeywords={keywords},  
    pdfnewwindow=true,     
    colorlinks=true,          
    linkcolor=black,          
    citecolor=black,
    filecolor=black,
    urlcolor=black
}

\begin{document}

\begin{figure}[H]
  \centering
  \includegraphics[width=0.8\textwidth]{lion.jpg}   
  \caption{Lion}
  \label{fig:lion}
\end{figure}

\autoref{fig:lion}

\end{document}
9
  • 2
    Welcome to TeX.SE...Please provide MWE from \documentclass to \end{document}
    – MadyYuvi
    Dec 20, 2022 at 10:38
  • 1
    As MadyYuvi suggests, please provide a full but minimal example that others can copy and test as is. Then it is a lot easier to see what exactly you are doing and suggest help. As it is now, we have no clue as to what you are doing, what class and packages etc.
    – daleif
    Dec 20, 2022 at 10:40
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Dec 20, 2022 at 10:48
  • 2
    Instead of graphics you should load graphicx.
    – Zarko
    Dec 20, 2022 at 11:03
  • 1
    Off-topic: Don't load the t1enc package; instead, run \usepackage[T1]{fontenc}. \usepackage[utf8x]{inputenc} may be omitted entirely, unless you're using a *really old" TeX distribution. (Like, more than 5 years old.) There can be no justification for loading the epsfig package, unless your TeX distribution is about 20 years old.
    – Mico
    Dec 20, 2022 at 14:28

1 Answer 1

5

You can use the cleveref package.

\documentclass[12pt,a4paper,magyar]{report}

\usepackage{t1enc}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage[thmmarks,amsmath]{ntheorem}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{listingsutf8}
\usepackage{color}
%\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{anysize}
\usepackage{babel}
\selectlanguage{magyar}
\usepackage{sectsty}
\usepackage{setspace}
\usepackage[hang]{caption}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{float}
\usepackage[euler]{textgreek}
\usepackage{booktabs}

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\marginsize{2.5cm}{2.5cm}{1.0cm}{1.0cm} % anysize package

\hypersetup{
    bookmarks=true,        
    unicode=false,           
    pdftitle={...},       
    pdfauthor={...},   
    pdfsubject={...}, 
    pdfcreator={...},   
    pdfproducer={Producer},   
    pdfkeywords={keywords},  
    pdfnewwindow=true,     
    colorlinks=true,          
    linkcolor=black,          
    citecolor=black,
    filecolor=black,
    urlcolor=black
}

\crefformat{figure}{#2#1.~ábra#3}

\begin{document}

\begin{figure}[H]
  \centering
  \includegraphics[width=0.8\textwidth]{lion.jpg}   
  \caption{Lion}
  \label{fig:lion}
\end{figure}

\cref{fig:lion}

\end{document}

Note that i moved the magyar option to the class declaration, as it is recommended to do so by the cleveref manual when using babel.

Here is another approach, but i don't know how robust it is. You can define a new command using \hyperref in the following way:

\documentclass[12pt,a4paper]{report}

\usepackage{t1enc}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage[thmmarks,amsmath]{ntheorem}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{listingsutf8}
\usepackage{color}
%\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{anysize}
\usepackage[magyar]{babel}
\selectlanguage{magyar}
\usepackage{sectsty}
\usepackage{setspace}
\usepackage[hang]{caption}
\usepackage{hyperref}
\usepackage{float}
\usepackage[euler]{textgreek}
\usepackage{booktabs}

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\marginsize{2.5cm}{2.5cm}{1.0cm}{1.0cm} % anysize package

\hypersetup{
    bookmarks=true,        
    unicode=false,           
    pdftitle={...},       
    pdfauthor={...},   
    pdfsubject={...}, 
    pdfcreator={...},   
    pdfproducer={Producer},   
    pdfkeywords={keywords},  
    pdfnewwindow=true,     
    colorlinks=true,          
    linkcolor=black,          
    citecolor=black,
    filecolor=black,
    urlcolor=black
}

\newcommand*\myref[2][ábra]{\hyperref[#2]{\ref*{#2}.~#1}}

\begin{document}
    
    \begin{figure}[H]
        \centering
        \includegraphics[width=0.8\textwidth]{example-image}   
        \caption{Lion}
        \label{fig:lion}
    \end{figure}
    
    \myref{fig:lion}
    
    \myref[ábrán]{fig:lion}
    
\end{document}
9
  • Okey, that is a neat solution but not precise, as I already said in my question, sometimes we are using, suffixes, so sometimes the ref output text should look like this: 1. ábrán, not 1. ábra
    – mala97
    Dec 20, 2022 at 11:33
  • @mala97 -- cleveref's \cref command and friends can handle only the nominative case. For other cases -- I'm afraid I have no idea how many cases Hungarian may have, let alone what they're called -- use \labelcref along with the appropriate case format.
    – Mico
    Dec 20, 2022 at 11:36
  • 1
    @mala97 I suppose what you are calling "suffixes" there are actually declension cases. Is this correct? If so, zref-clever does have some support for it (ctan.org/pkg/zref-clever), but (at least currently) has no localization for Hungarian.
    – gusbrs
    Dec 20, 2022 at 13:05
  • 1
    @Mico ^^^ You may be interested as well.
    – gusbrs
    Dec 20, 2022 at 13:05
  • 1
    @mala97, After some thoughts you might want to change the space in the hyperlink to be unbreakable, by replacing the space with ~. also you should probably use \newcommad* and not \newcommand.
    – Udi Fogiel
    Dec 20, 2022 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .