I am trying to build a controlled dictionary. I used a template where it's defined a command to insert a new entry. I would like to assign a label to each entry so that I can link similar terms with hyperref package. If I insert the label each time it works but it's quite a tedious task. I would like to insert the label with the same name of the entry, directly in the command as shown in my attempt below however it does not work. I studied this question but I could not find a solution to my problem.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=20mm]{geometry}
\usepackage{hyperref}
\newcommand{\entry}[4]{ \scriptsize{\markboth{#1}{#1}\textbf{#1}\ {(#2)}\ \textit{#3}\ $\bullet$\ {#4}}}
%my atempt
\newcommand{\autoentry}[4]{\label{ter:{#1}}\scriptsize{\markboth{#1}{#1}\textbf{#1}\ {(#2)}\ \textit{#3}\ $\bullet$\ {#4}}}
\begin{document}
% expected behaviour but slow
\entry{myword}{myword}{ \label{ter:myword} masdfa asldkfj asld}{test}
% my attempt
\autoentry{myword2}{myword2}{ masdfa asldkfj asld}{test}
\hyperref[ter:myword]{myword}
\hyperref[ter:myword2]{myword2}
\end{document}
The error that I've got is this one:
You have referenced something which has not yet been labelled. If you have labelled it already, make sure that what is written inside \ref{...} is the same as what is written inside \label{...}.
\label{ter:#1}. – Ulrike Fischer Apr 09 '20 at 12:00