I have been looking all over the internet trying to figure out how to automatically set a macro to make section include a label for its name (or something based on its name if spaces or something is problematic, i.e. if I define \section{related work} I want to be able to use \ref{sec:related work} or maybe \ref{sec:related_work} or something similar
I have also been trying to use section number as a second choice using counters, but I failed miserably. (it seems \arabic cannot be a part of \label{} making this solution not work (perhaps it won't work even with it, I am not sure how counters + macros act, but did not reach this part)
\usepackage{letltxmacro}
\LetLtxMacro{\oldsection}{\section}
\renewcommand{\section}[2][]{\oldsection[#1]{#2}\index{#1}\label{sec:\arabic{section}}

\labelat all. The whole idea is that you can edit the docuemnt, adding new sections, all the sections renumber and all cross references still work. Your suggestion would have you use\ref{sec:2}which will make the wrong reference if the sections have been changed, – David Carlisle Jan 30 '18 at 13:05\section{Something about something}\label{x}and references\ref{x}scattered through the document, and an editor tells you to use\section{Something About Something}then you only need change the title in one place, and all references work, if you have used multiple\ref{Something about something}then you need to change every reference if you edit the title. – David Carlisle Jan 30 '18 at 14:01\section*usages... – Jan 30 '18 at 16:49