LyXProblem with cross-reference and label

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
lyxrocks
Posts: 91
Joined: Sat Oct 23, 2010 5:59 pm

Problem with cross-reference and label

Post by lyxrocks »

I am using this template to write a math paper.
class-selection.jpg
class-selection.jpg (66.66 KiB) Viewed 5133 times
I cannot get it to reference to a lemma, I want it to say "according to lemma 1" but it says "according to [1]" treating my labeled lemma as a labeled equation.
LyX-result.jpg
LyX-result.jpg (23.55 KiB) Viewed 5133 times
thanks in advance!
Last edited by localghost on Tue Jul 10, 2012 10:06 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

lyxrocks
Posts: 91
Joined: Sat Oct 23, 2010 5:59 pm

Re: Problem with cross-reference and label

Post by lyxrocks »

anyone?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Problem with cross-reference and label

Post by cgnieder »

I don't know anything about LyX but this is standard LaTeX behaviour: the \ref command (which surely is used) only prints the number of the referenced label. So you have to add the type yourself (Lemma~\ref{<whatever label has been used>}).

Code: Select all

\documentclass{elsarticle}

\newtheorem{lem}{Lemma}
\newproof{pf}{Proof}

\begin{document}

\begin{lem}\label{lem:aaa}
 aaa
\end{lem}
\begin{pf}
 aaa
\end{pf}

\begin{lem}
 bbb
\end{lem}
\begin{pf}
 According to Lemma~\ref{lem:aaa}
\end{pf}

\end{document}
There are packages like cleveref or varioref which provide means to add the name automatically. I would think there should be a way to use them with LyX as well:

Code: Select all

\documentclass{elsarticle}

\newtheorem{lem}{Lemma}
\newproof{pf}{Proof}

\usepackage{cleveref}
\crefname{lem}{Lemma}{Lemmata}
\begin{document}

\begin{lem}\label{lem:aaa}
 aaa
\end{lem}
\begin{pf}
 aaa
\end{pf}

\begin{lem}
 bbb
\end{lem}
\begin{pf}
 According to \cref{lem:aaa}
\end{pf}

\end{document}
Regards
site moderator & package author
lyxrocks
Posts: 91
Joined: Sat Oct 23, 2010 5:59 pm

Re: Problem with cross-reference and label

Post by lyxrocks »

thanks.
Post Reply