This question already has an answer here:

I use my own version of subsections for definitions:

\newcommand{\definition}[2]{\addtocounter{subsection}{1} \subsection*{\thesubsection ~ Definition (#1) \text{\normalfont{#2}}}}

I use them as:

\definition{DefinedThing}{\cite{Book}[Page 64]}

This works great, the only problem I have is that the references do no longer work now:


This reference does only refer to the section in which the definition is used, not to the actual subsection it represents (for example it refers to "2" instead of to "2.5"). Is there a way to fix this? Maybe by increasing the counter for the \label{}.

marked as duplicate by Werner sectioning Dec 22 '15 at 1:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    use \refstepcounter – daleif Nov 13 '15 at 13:20
  • I tried it but I could not yet figure out if this works. If you have a working peace of code, I would really appreciate it. – user92048 Nov 13 '15 at 13:45
  • Then you should start by posting a minimal example that compiles. Then it is a lot easier to help. BTW: what is that \text doing there? \text is for textual comments in displayed math, not for constructions like this. – daleif Nov 13 '15 at 14:11
  • Just replace \addtocounter{subsection}{1} by \refstepcounter{subsection} but better would be to use \subsection instead of \subsection* – David Carlisle Nov 13 '15 at 14:11
  • Thank you for your answers. The tip of David helped me. The sections are now displayed correctly. – user92048 Nov 13 '15 at 16:18