2

I use zref, but the numbers are not correctly displayed for align environments (they are for equation, though).

example:

\documentclass{report}
\usepackage{amsmath}
\usepackage{zref}
\usepackage{zref-user}

\begin{document}
    \chapter{a}
    \begin{align}
        a \zlabel{eq:a} \\
        b \zlabel{eq:b}
    \end{align}
    test: \zref{eq:a}, \zref{eq:a}
    \begin{equation}
        c \zlabel{eq:c}
    \end{equation}
    test2: \zref{eq:c}
\end{document}

enter image description here

I need the zref package since I want to reference other subfiles.

Also: figure references don't seem to work at all.

What am I doing wrong?

  • Welcome to TeX.SX! \numberwithin has nothing to do with the issue, so I removed it from your question. The output is exactly the same. – egreg Nov 20 '17 at 18:15
  • The issue isn't limited to instances of align environments -- it crops us with gather environments as well. – Mico Nov 20 '17 at 19:30
1

First question: Environments of package amsmath

The environments of amsmath process the contents twice. The first run measures the width and the second run sets the equations. Also, they support \notag and friends. The is that the support of \label is quite hard-wired into the environments. Other label as \zlabel are not supported.

A (crude) workaround:

  1. Use of \label inside the environments of package amsmath.
  2. Import of the \labels as \zlabels via zref-xr.
  3. Then the imported labels can be accessed by \zref with or without prefix, specified in the second step.

Example with prefix:

\documentclass{report}
\usepackage{amsmath}
\usepackage{zref}
\usepackage{zref-user}
\usepackage{zref-xr}

\zexternaldocument*[self:]{\jobname}

\begin{document}
    \chapter{a}
    \begin{align}
        a \label{eq:a} \\
        b \label{eq:b}
    \end{align}
    test: \zref{self:eq:a}, \zref{self:eq:b}
    \begin{equation}
        c \zlabel{eq:c}
    \end{equation}
    test2: \zref{eq:c}
\end{document}

Result

Second question: Figure references

References for \captions in figures or tables work as expected:

\documentclass{report}
\usepackage{zref}
\usepackage{zref-user}

\begin{document}
\chapter{a}
\begin{figure}[h]% "h" as exception to get a smaller image for TeX.SX.
  \caption{Figure caption}
  \zlabel{fig:caption}
\end{figure}
Test: \zref{fig:caption}
\end{document}

Result

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.