# How to print something that in each section on the first page

I want to reference some numbers in each section on the first page of the document. But I can't find any package to do this.

\documentclass{article}
%\usepackage{zref}
\begin{document}
\section{mytitleone}
%2 5 7 is supposed to be here by any amazing packages.

\section{mytitletwo}
2
something.
\section{mytitlethree}
5
Something.
\section{mytitlefour}
7
Something.
\end{document}


EDIT Actually, I have a number in each section and I have to put those numbers in a table on the begin of the document.

• @JouleV no. I want 2 5 7 to be printed there automaticlly. – Brooks Feb 14 '19 at 13:00
• Then what identifies 2, 5 and 7? Why not, for instance, 1, 6, or 10? – user156344 Feb 14 '19 at 13:02
• @JouleV this is done by my hand – Brooks Feb 14 '19 at 13:03
• @JouleV no rules for these nums – Brooks Feb 14 '19 at 13:07
• While \label normally saves the result of the last \refstepcounter, you can put pretty much anything into a custom version. See tex.stackexchange.com/questions/236626/…. – John Kormylo Feb 14 '19 at 16:52

Arbitrary anchors can be placed in a document with hyperref's hypertarget, and then referenced with hyperlink -- see LaTeX/Hyperlinks.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{mytitleone}%2 5 7 is supposed to be here by refference.
\hypertarget{mytarget}{}% Empty target caption
\section{mytitletwo}
something.
\section{mytitlethree}
Something.
\section{mytitlefour}
Something.
\end{document}


Output (links shown with a red box):

Edit - After a comment exchange established that OP essentially wanted functionality provided by the label command in this answer. I've added a variant of this command which doesn't print any text (see below). Example:

\documentclass{article}
\usepackage{hyperref}
% From https://tex.stackexchange.com/a/54857/172926
\makeatletter
\newcommand*{\textlabel}[2]{%
\edef\@currentlabel{#1}% Set target label
#1\label{#2}% Print and store label
}
\makeatother
\makeatletter
\newcommand*{\mylabel}[2]{%
\edef\@currentlabel{#1}% Set target label
\label{#2}% Store label
}
\makeatother
% Example for OP
\begin{document}
\section{First section}
\begin{table}
\begin{tabular}{l|l}
Section & Reference\\\hline
2& \ref*{section2number}\\
3& \ref*{section3number}\\
\end{tabular}
\end{table}
\section{Second section}
\mylabel{3}{section3number}
\section{Third section}
\textlabel{7}{section2number}
\end{document}


\mylabel{3}{name} creates a label called name which provides a value of 3 (for example) when referenced. \textlabel{7}{name} functions in a similar way but also prints the value at the labels location.

Output:

• I am not want to get a hyperlink here. – Brooks Feb 14 '19 at 15:49
• Right, I see the edit. You use the tabular environment for tables - see tablesgenerator.com – Pippip19 Feb 14 '19 at 15:55
• but supposed you want to make a .cls file. – Brooks Feb 14 '19 at 15:59
• the problem is that I must put something you write which I don't know before it occur. It's not to have the table on the end of document. – Brooks Feb 14 '19 at 16:55
• Okay, so you're essentially are looking to do the reverse of what I did in my answer, but without the links? So you write '2' in section 2 and '2' appears in the table at the start? We can do that (let me know and I'll edit answer). – Pippip19 Feb 14 '19 at 17:57

Using counters as suggested by John, you insert the number where you want and give a label to it with the command \putctr{number}{label} and then you refer to it using \refctr{label} passing the label you gave.

\documentclass[11pt,a4paper]{article}

\newcounter{myctr}
\newcommand{\putctr}[2]{%
\setcounter{myctr}{#1}%
\refstepcounter{myctr}%
\label{ctr:#2}%
\themyctr
}
\newcommand{\refctr}[1]{\ref{ctr:#1}}
\begin{document}

refering the numbers: \refctr{A}, \refctr{B}, \refctr{C}

\section{title}
first use: \putctr{2}{A}

\section{title}
second use: \putctr{7}{B}

\section{title}
third use: \putctr{5}{C}

\end{document}


\documentclass{article}
\makeatletter
\newcommand{\mylabel}[2]{%
\protected@write\@auxout{}{%
\string\newlabel{#1}{{#2}{\thepage}}}}
\makeatother
\begin{document}
\section{one}
\ref{mynum:1}
\ref{mynum:2}
\ref{mynum:3}
\mylabel{mynum:\thesection}{7}
\section{two}
\mylabel{mynum:\thesection}{19}
\section{three}
\mylabel{mynum:\thesection}{57}
\end{document}


Then we can use the package interfaces-makecell to generate the table automatically by \repeatcell and \ref{mynum:\row}. However, I use package zref to get the totoal sections.