10

In my document I have a customized list subtasks type (using enumitem) to insert subtasks. I would like to reference them using \autoref. However, since these are lists, \autoref inserts the word "item" before the label, where I would like to have "subtask".

If I just use \def\itemautorefname{subtask} all items in all lists will be reference with the word "subtask".

Is there a way to only change the autoref name for items of the subtasks list?

1
  • 2
    Please post the code that defines the "subtask" enumerated environment. Better yet, please post a full MWE that shows what you've tried to accomplish so far.
    – Mico
    Commented May 24, 2014 at 17:42

1 Answer 1

8

I can't give you an answer for how to get \autoref to show "Subtask" instead of "Item". Fortunately, it's straightforward to provide a solution that uses the cleveref package and its \cref cross-referencing command. With \cref, it's also easy to create multiple cross-references with a single command. (In the MWE, hyperref is loaded only to create hyperlinks, not to create cross-references.)

enter image description here

\documentclass{article}

\usepackage{enumitem}
\newlist{subtask}{enumerate}{1}     % this creates a dedicated counter named 'subtaski'
\setlist[subtask,1]{label=\arabic*} % set form of enumeration label here

\usepackage[colorlinks=true]{hyperref}

\usepackage[nameinlink]{cleveref}      % 'nameinlink' option emulates look of \autoref
\crefname{subtaski}{subtask}{subtasks} % set prefix for items of type 'subtaski'

\begin{document}
\begin{subtask}
\item Uno \label{subtask:1}
\item Dos \label{subtask:2}
\item Tres\label{subtask:3}
\end{subtask}

A cross-reference to \cref{subtask:2}.

As stated in \cref{subtask:3,subtask:1}, \dots
\end{document} 

You must log in to answer this question.

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