0

I use the cleveref to cross-reference my equations and I have no problems with the equation and align environments. However, when using the gather environment, the cross-reference reads: "Section x.y.z" instead of "Equation x.a".

How to ensure that cleveref refers to gather as equations?

MWE

Note that I have an appendix wher I changed the "section" printed by 'cleveref' to "appendix".

% !TeX program = lualatex

\documentclass[class=book]{tudapub}


\usepackage[english]{babel}
\usepackage{amsmath} % Bold math symbols

\usepackage[nameinlink]{cleveref} % For capitalized ref
\usepackage{appendix} % Needed to trigger clevref names change for appendix sections


\AtBeginEnvironment{appendices}{\crefalias{section}{appendix}} % To rename sections in clevref when entering appendices
\AtEndEnvironment{appendices}{\crefalias{section}{section}} % To rename sections back in clevref when leaving appendices


\begin{document}
    
    \chapter{My chapter}
    
    
    \section{My section}

    This is an equation in the 'equation' environment:
    \begin{equation}
    \label{Eq_equation}
    a = b
    \end{equation}
    
    This is an equation in the 'align' environment:
    \begin{align}
    \label{Eq_align}
    a &= b
    \nonumber \\
    c &= d
    \end{align}
    
    This is an equation in the 'gather' environment:
    \begin{gather}
    \label{Eq_gather}
    a = b
    \nonumber \\
    c = d
    \end{gather}
    
    I can use the package 'cleveref' with 'equation' and 'align: these are cross-references to \Cref{Eq_equation} and \Cref{Eq_align}.
    
    But it does not work with 'gather': this is a cross-reference to \Cref*{Eq_gather}.
    
\end{document}
6
  • 2
    Could you please post a minimal (non)working complete code?
    – Bernard
    Oct 29 '20 at 10:12
  • 1
    Using the simplest of MWEs I have no issues with cleveref and gather so please provide code as Bernard mentions.
    – daleif
    Oct 29 '20 at 10:18
  • @Bernard Yes, sorry it took a while to get a MWE from my whole thesis. It is now added to the question.
    – JuCa
    Oct 29 '20 at 10:43
  • 1
    you have used the label on an unnumbered line, what do you want it to refer to? Oct 29 '20 at 10:45
  • @DavidCarlisle To the equation 1.2 composed of the two lines. This is currently the behaviour I am looking for with the 'align' environment
    – JuCa
    Oct 29 '20 at 10:47
1

In gather each line is numbered separately and so can have a separate label, in this case the \label is in an unnumbered like due to \nonumber so it references the currently active label which is typically the most recent section heading.

The same ought to be true of align but the processing of align is more involved and if it picks up something more useful in that case, that is by accident not design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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