TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 4 down vote accepted

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} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.