In Lyx 2.0, I'm trying to use a formatted reference to a claim, but I cannot get the "formatted" part, i.e. I can't get it to typeset "claim" as well as the claim number.
I'm using modules "Theorems (Numbered by type)" and "Theorems (Numbered by type within sections)". I have a paragraph in the "Claim" environment, with a label "claim:1". (I got the "claim:" part in there by editing ../Resources/layouts/theorems-refprefix.inc
, but I had the same behavior before I made this change.) I later put in a formatted reference which generates tex code as "\claimref{1}
". This typesets to "… 1.1 …" in the output, i.e. just section and claim counter number. What I'd like to see is "… claim 1.1 …"
If I change these claims to theorem environments AND delete and remake the labels (so "thm:1") and update the references, the formatted reference typesets the word "theorem" for the reference, as desired. Lemma does not seem to work (though I may not have remade all the lables.)
I do see Lyx adding this to the preamble:
\AtBeginDocument{\providecommand\claimref[1]{\ref{claim:#1}}}
I also see
\RS@ifundefined{thmref}
{\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}}
{}
which I can't trace the origin of, but it may explain why theorem works.
Any ideas?
Best Answer
Add to the document preamble (Document --> Settings --> LaTeX preamble)
and it will probably work. As mentioned by egreg in the comments, the
refstyle
package is used, and you have to tell it what it should insert for labels starting withclaim:
.refstyle
also provides commands for start-of-sentence references (capital letter) and plural forms, and the words to insert in these cases can also be specified, e.g.I don't know, however, how to make LyX use these, other than through using an ERT, with e.g.
\Claimref{claim:1}
. See therefstyle
documentation for details.Example
Copy the following code to an empty file and save as a
.lyx
file, e.g.example.lyx
. Open in LyX and compile. Screenshots of LyX view and PDF below.