# Markers in document for custom TOC

What I would like to do is place markers with custom keys into my document to generate a TOC from. I imagine this to look something like the following:

\Section{A}
Lorem impsum
\marker{foo}
Neque porro

\Section{B}
Quisquam est qui\marker{bar}


Using these markers I would like to create a page listing all markers together with the corresponding page numbers like so

foo......p.1
bar......p.2


Is there any way / command to achieve a similar behavior in latex? Alternatively I would also be happy if there was some postprocessing command with which I could extract the position of these markers in the final pdf without actually listing/seeing them.

• you can try with etoc package. – touhami Mar 26 '18 at 22:31

Here is a suggestion using package tocbasic:

\documentclass{article}
\usepackage{tocbasic}
\DeclareNewTOC[
owner=\jobname,
type=marker,
listname={List of Markers},
tocentrylevel=1,
tocentrystyle=tocline,
tocentryindent=0pt,
tocentrynumwidth=0pt
]{mrk}
\newcommand\marker[1]{%
}

\usepackage{lipsum}
\begin{document}
\listofmarkers
\section{A}
Lorem impsum
\marker{foo}%
Neque porro
\lipsum[1-10]
\section{B}
Quisquam est qui\marker{bar}
\end{document}


Result: