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}

\usepackage[linktocpage=true,
pagebackref=true,colorlinks,
linkcolor=DarkRed,citecolor=ForestGreen,
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
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s