Graphics, Figures & TablesFloat Label in Cross Reference

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Float Label in Cross Reference

Post by azizever83 »

Hello there,

I am trying to use \label and \ref to automatically refer to the figure. However the problem is that the label (Figure) doesn't appear in the output file. I have to write it manually. Here is my way and the output file.

Code: Select all

\begin{figure}[H]
\caption{Picture}
\centering
\includegraphics[scale=1]{45042_101726753222359_606717_n.jpg}
\label{Pic}
\end{figure}

see ~\ref{Pic} for more details
and the output is as in the attached picture. Is there any specific package that I have to use?

Thanks in advance...
Attachments
The obtained result.
The obtained result.
CrossReference.jpg (10.76 KiB) Viewed 3428 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Float Label in Cross Reference

Post by cgnieder »

Have a look at the package cleveref:

Code: Select all

\documentclass{article}
\usepackage{cleveref}

\begin{document}

\section{Test}\label{sec:test}

Here is \cref{sec:test}

\end{document}
Regards
site moderator & package author
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Re: Float Label in Cross Reference

Post by azizever83 »

Hello,

this seems helpful, thanks. But, I need to get "Figure" rather than just "fig". Thanks and sorry. That is required for my writing.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Float Label in Cross Reference

Post by cgnieder »

There's also varioref, hyperref's \autoref, nameref … one of these should provide means. Also cleveref has a wide range of macros and options. It should also be able to customize it to achieve what you want. Have a look at the documentation: cleveref.

Regards
site moderator & package author
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Re: Float Label in Cross Reference

Post by azizever83 »

Hi cgnieder,
thanks a lot for you effort. this was very helpful...
Post Reply