18 Comments

  1. Good morning,

    As soon as I saw that, I thought “how cool”. So, I went to the paper I am working on now, and added \usepackage{cleveref}, replaced all \ref by \cref, and compiled but it didn’t work: all references where now “??”. So, I deleted all the aux files, and tried again, but it still didn’t work. Therefore, this doesn’t work for me. Any idea why?

    • Hi Guillaume,

      Thanks for your comment. It’s all there in bold, under “Clickable references with hyperref”.

      Cheers, Tom

      • Hi Tom,

        I found out something else: the references didn’t work properly for the figures until I figured out that I needed to put the label inside the caption. Otherwise, I put the number of the section instead of the figure. I tried to put the label right at the start, right at the end, in the \centre, before the caption, and nothing worked other than putting it inside the cation. Maybe this is only the case with the emulateapj document class, but in any case, it might be useful to some other astrophysicist that reads your blog.

  2. Hi Tom: Did you, by any chance, have time to look into why \cref for sections doesn’t work in emulateapj.cls? A fix for this would be great. Ciao. Guillaume

    • tom

      Hi Guillaume,

      I downloaded the emulateapj class file and used it with the multiple labels example above. In the example, \label is outside \caption. The example works for me as long as I use \label after \caption.

      If this doesn’t solve your problem, please provide a minimal working example and I’ll look into it.

      Thanks, Tom

      • Hi Tom. Thanks a lot for looking into it. The problem is not for Figures; that works for me (with label outside the caption). It’s for Section; it gives ?? instead of the ref. Here is my min “working” example where I have stripped the paper I’m working on now to leave only the relevant bits.

        \begin{document}
        
        \title{Towards Unifying Time Domain Astronomy}
        \shorttitle{Towards Unifying Time Domain Astronomy}
        
        \author{G.\ B\'elanger}
        \affil{European Space Astronomy Centre (ESA/ESAC), Science Operations Department, \\ Villanueva de la Ca\~nada (Madrid), Spain; \\ \href{mailto:gbelanger@sciops.esa.int}{gbelanger@sciops.esa.int}}
        
        \begin{abstract}
        Time domain astronomy concerns itself with the study of astrophysical systems by characterising the properties of the light they emit in order to deduce and infer something about the physical mechanisms that could be responsible for giving rise to this emission.
        \end{abstract}
        \keywords{methods: data analysis -- methods: statistical}
        
        \section{Introduction}
        
        The task is divided in three the categories mentioned earlier, which relate to the characterisation of constance, which also includes searching for new or transient sources (Section \ref{s:constancy}); periodicity at any scale and whatever the nature (\cref{s:periodicity}); and stochastic variability, including the tracing and detection of state changes (\cref{s:variability}).
        
        \section{Characterising Constancy}
        \label{s:constancy}
        
        \section{Characterising Periodicity}
        \label{s:periodicity}
        
        \section{Characterising Stochastic Variability}
        \label{s:variability}
        
        \end{document}
      • tom

        Hi Guillaume,

        After trying for some time, I don’t think I’ll be able to come up with a solution within a reasonable amount of time. If the problem only occurs for sections, you might just want to define your own command:

        \newcommand\sref[1]{Section \ref{#1}}

        If you rather use the cleveref package, consider submitting your question to tex.SX.

        Best, Tom

  3. Nice write up.

    I’m obviously biased, but `refstyle` is not a `cleveref` rival in any meaningful sense. As I understand, it provides a series of \eqref, \figref, \secref etc. commands for produces cross-references to equations, figures, sections, etc. It doesn’t automatically detect the type of thing you’re references and format it appropriately. So you have to use one command for referencing equations, a different one for figures, yet another for sections etc. This might save a few characters of typing (“\figref” instead of “Figure~\ref”), but not much else. Even the old `smartref` package does something more sophisticated.

    And that’s not to mention all the other `cleveref` features that have no equivalent in `refstyle` (e.g. multi-references).

    • tom

      Thanks for your comment and for creating this invaluable package! Would you be interested in writing a guest post here, possibly discussing some more advanced features of your package?

      Best wishes, Tom

  4. Kerina

    1. Is it possible to use only cleveref (and not use hyperref at all)?

    2. Does cleveref have any problems with polyglossia (like hyperref does with polyglossia)?

    Thanx.

Leave a Reply