4

This is a follow-up question to the previous questions:

The code below

\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\makeatletter
\newcounter{step}
\renewcommand*{\thestep}{(\textbf{Task~\arabic{step}})} % needed
\newcommand*{\TASK}[1]{%
  \begingroup
    \refstepcounter{step}%
    \label{#1}%
    \thestep
  \endgroup
}
\newcommand*{\REF}[1]{%
  \begingroup
    \refstepcounter{step}%
    \phantomsection
     \ref{#1}
  \endgroup
}
\makeatother
\begin{document}
text1 \TASK{t.limit} referenced as \REF{t.limit}.
\end{document} 

gives me a text like this:

enter image description here

How should I modify it so that by writing

text1 \TASK{t.limit}{Limit behavior} referenced as \REF{t.limit}.

or something similar, I get the output below?

enter image description here

Ali
  • 883

1 Answers1

4

You can do it by modifying \thestep to also include the additional text:

enter image description here

Code:

\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\makeatletter
\newcounter{step}

\newcommand{\Decription}{}% \renewcommand{\thestep}{(\textbf{Task~\arabic{step}}\Decription)} % needed \newcommand{\TASK}[2]{% \begingroup \xdef\Decription{: #2} \refstepcounter{step}% \label{#1}% \thestep \endgroup } \newcommand{\REF}[1]{% \begingroup \refstepcounter{step}% \phantomsection \ref{#1} \endgroup } \makeatother \begin{document} text1 \TASK{t.limit}{Limit behavior} referenced as \REF{t.limit} \end{document}

Peter Grill
  • 223,288