# Cleveref in Lyx

It is really tricky to make a nice-looking cross reference in lyx. I managed to do it. So I share it here for me in the future.

\usepackage{xcolor}
\usepackage{nameref}

\definecolor{ForestGreen}{rgb}{0.1333,0.5451,0.1333}
\definecolor{DarkRed}{rgb}{0.8,0,0}
\definecolor{Red}{rgb}{1,0,0}

bookmarks,bookmarksopen,bookmarksnumbered]
{hyperref}

\usepackage{cleveref}

\crefalias{thm}{theorem}

\let\oldlem\lem
\renewcommand{\lem}{%
\crefalias{thm}{lemma}
\oldlem
}

\let\olddefn\defn
\renewcommand{\defn}{%
\crefalias{thm}{definition}
\olddefn
}

\renewcommand\equationautorefname{\@gobble}

\AtBeginDocument{%
\let\ref\Cref
}