Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 3 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
add comment

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.