# How to make a really basic reference?

I'm trying to make a really basic reference.

Let's say I have theses lines in my document :

Lorem Ipsum ...
Lorem Ipsum ... [1] here ... Lorem Ipsum ...
Lorem Ipsum ...


I want to anywhere in my document make a reference to [1] here.

I thought it would be simple to find out but I searched for too long and I got confused with all the sets and making a simple reference now seems to be like rocket-science to me.

I want the following result :

When clicking on the colored number 1, the line [1] here get at the top of my document viewer so the user feels easy to find the line directly.

-

The hyperref package provides the pair of commands

\hypertarget{<name>}{<text>}


for the creation of cross-references that are independent from counters. They are analogues of \label and \ref, respectively. Here's an example:

\documentclass{article}

\begin{document}

\newpage
The first hyperlink brings you \hypertarget{lip}{here.}
\newpage
The second hyperlink brings you \hypertarget{lipsys}{here.}

\end{document}


On the other hand, if you wish associate cross-references to a counter, you can try using the following declarations:

\documentclass{article}

\usepackage{etoolbox}

\newrobustcmd*{\foo}[1]{{\refstepcounter{bar}\label{#1}\thebar}}

\newcounter{bar}
\renewcommand{\thebar}{\textcolor{black}{[}\arabic{bar}\textcolor{black}{]}}

\begin{document}

Go to \ref{lipsys}, and \ref{lip}.
\newpage
The second hyperlink brings you \foo{lip} here.
\newpage
The first hyperlink brings you \foo{lipsys} here.

\end{document}


In the example above, \foo{<key>} (1) globally increments the counter bar, (2) maps the key to the current reference string, and (3) prints the value of bar. \textcolor{black}{...} is used to override the formatting applied by the hyperref package (otherwise it's typeset in the same colour as the counter).

-
 perfect ! thank you, it was not that hard finally and now my document has the look I want, Regards~ – Oddant Mar 2 at 21:05 and +1 for the counter solution – Oddant Mar 2 at 21:09 @Oddant you're very welcome. – nnunes Mar 2 at 21:53