[XeTeX] Counter reset problem

Diederick C. Niehorster dcnieho at gmail.com
Sat Sep 19 04:52:11 CEST 2009


Hi, Sorry to hijack this thread, but my question is related.

I'm writing an article with multiple studies and experiments in there.
I would like to use \cref (like \autoref) to automatically produce
e.g. "Study 2".

I am having trouble finding out how \cref and \autoref (both don't
work now) determine in what kind of environment the label was
produced. In the test document below, cleveref produces "section" and
autoref seems to be unable to figure it out, it produces: ""

>From studying other source code, i thought the trick was for labels in
environment "study" to work, you need commands like "\studyname" to
exist. there seems to be more, what am i missing?

By the way, note that I only use this new environment to make the
label have the right type, the environment will not contain anything.
If there is a better way of achieving what I want, please let me know.

Thanks!
Diederick

\documentclass{article}

\usepackage{hyperref}
\usepackage{cleveref}

% study counter
\makeatletter
\newcommand*\studyname{Study}
\newcounter{study}
\renewcommand*\thestudy{%
  \@arabic\c at study
}
\newcommand*{\studyformat}{%
  \studyname~\thestudy%
}
\makeatother
\newenvironment{study}[1]{%
\stepcounter{study}%
\label{st:#1}%
}{}

\begin{document}
\section{Introduction}
  stuff will be discussed in
  \Cref{st:stud} - \autoref{st:stud}

\section{Study 1}
  \begin{study}{stud}\end{study}
  \subsection{Introduction}
    This study (\thestudy) will present

\end{document}


More information about the XeTeX mailing list