# How to number labeled equations with different files?

I have a file main.tex

\documentclass{article}

\usepackage{xr-hyper}
\usepackage{hyperref}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}

$$\label{sec:mytitle} 1 + 1 = 2$$

\end{document}


and ref.tex

\documentclass{article}

\usepackage{xr-hyper}
\hypersetup{
filecolor={red}, %<----
urlcolor={blue},
citecolor={blue}
}

\externaldocument[ex:]{external}

\begin{document}

\section{My section}\label{sec:mysection}

Local ref: \ref{sec:mysection}, external ref:  \ref{ex:sec:mytitle}

\end{document}


I use showonlyrefs option in main.tex to minimize the numbering. However, I may have some equations that I will only call in ref.tex. These equations will not be numbered in main.tex by showonlyrefs. Is there any way I could overcome this?

• See the mathtools manual, there is a macro similar to nocite for that Oct 9, 2019 at 9:33

Simply add \noeqref{sec:my_title} in main.tex.
Indeed, as the comment by @daleif points out, the documentation for the mathtools package discusses the \noeqref, which is similar to \nocite for bibliography items.