I have seen other issues about cleveref and thmtools (A problem with thmtools and cleveref, Problem with hyperref / cleveref / thmtools, How do I get rid of particular pdftex warning message?), but they are not exactly like mine.
What I have done:
I use both packages in a book environment, I defined theorem and lemma (with numberline=theorem) environments using thmtool and I define one lemma in the first chapter and a second one in the second chapter. I use \ref or \cref to cite the second lemma.
What I get: I have the following warning
pdfTeX warning (ext4): destination with the same identifier (name{lemma.1}) has been already used, duplicate ignored
and in practice, the right label is showed in the pdf, but the hyperlink links with the first lemma.
Any ideas on how to fix it ?
Here's a MWE:
%!TEX encoding =UTF-8 Unicode
\documentclass{book}
%%%============== Packages
% \usepackage{fontspec}
\usepackage[utf8]{inputenc}
% Permet de gerer les accents en francais
\usepackage[T1]{fontenc}
% \usepackage{amsthm}
% \newtheorem{theorem}{Theorem}[chapter]
% \newtheorem{lemma}[theorem]{Lemma}
\usepackage{thmtools}
\declaretheorem[numberwithin=chapter,name=Theorem,
refname={theorem,theorems},
Refname={Theorem,Theorems}]{theorem}
\declaretheorem[numberlike=theorem,name=Lemma,
refname={lemma,lemmas},
Refname={Lemma,Lemmas}]{lemma}
% Creation de liens hypertextes (cliquables)
\usepackage{hyperref}
% Creation de liens hypertextes (cliquables)
\usepackage[capitalise,noabbrev]{cleveref}
\title{Packages clash}
\begin{document}
\chapter{First}
\section{Section 1 1}
\begin{lemma}\label{lem:1}
Lemma 1
\end{lemma}
\chapter{Second}
\section{Section 2 1}
\begin{lemma}\label{lem:2}
Lemma 2
\end{lemma}
\section{Section 2 2}
\ref{lem:2}
\end{document}
amsthmandcleveref(it did not recogniselemma), and the solution was the same and documented in 14.1 of the documentation. May be another "non-bugs" about mathtool could be added to the section, I will ask the maintainer. – Pierre Marchand Jul 01 '19 at 16:02cleverefis quite cunning at figuring out various things, it does need to have been loaded by the time\declaretheorem(in case ofthmtoolspackage) or\newtheorem(in the case ofamsthm) statements are executed. Interestingly, if thentheorempackage is employed, it is not strictly necessary to have loadedcleverefbefore various\newtheoremdirectives are executed. – Mico Jul 01 '19 at 18:58