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.

\usepackage[a4paper, margin=20mm]{geometry}
\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}}} 

% expected behaviour but slow
\entry{myword}{myword}{ \label{ter:myword} masdfa asldkfj asld}{test}
% my attempt  
\autoentry{myword2}{myword2}{ masdfa asldkfj asld}{test}


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{...}.

  • 1
    Remove the braces in the label: \label{ter:#1}. Commented Apr 9, 2020 at 12:00
  • Thanks this solved the problem, if you formalize this in an answer I can close this question.
    – G M
    Commented Apr 9, 2020 at 13:23

1 Answer 1


With \label{ter:{#1}} the inner braces are part of the label name. They are stored in aux-file:


So either remove them in your definition


Or add the braces to the reference:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .