Add to the document preamble (Document --> Settings --> LaTeX preamble)
\newref{claim}{name=claim~}
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 with claim:
.
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.
\newref{claim}{name=claim~,Name=Claim~,names=claims~,Names=Claims~}
I don't know, however, how to make LyX use these, other than through using an ERT, with e.g. \Claimref{claim:1}
. See the refstyle
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.
#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass article
\begin_preamble
\newref{claim}{name=claim~}
\end_preamble
\use_default_options true
\begin_modules
theorems-bytype
theorems-sec-bytype
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Section
Something
\end_layout
\begin_layout Claim
\begin_inset CommandInset label
LatexCommand label
name "claim:claim1"
\end_inset
I hereby claim that I don't use LyX.
\end_layout
\begin_layout Theorem
\begin_inset CommandInset label
LatexCommand label
name "thm:1"
\end_inset
LyX makes some things harder.
\end_layout
\begin_layout Standard
Inserting references:
\begin_inset CommandInset ref
LatexCommand formatted
reference "thm:1"
\end_inset
and
\begin_inset CommandInset ref
LatexCommand formatted
reference "claim:claim1"
\end_inset
.
\end_layout
\end_body
\end_document
Requires amssymb
for the black square.
\newenvironment{claim}[1]{\par\noindent\underline{Claim:}\space#1}{}
\newenvironment{claimproof}[1]{\par\noindent\underline{Proof:}\space#1}{\hfill $\blacksquare$}
You can edit and use Claim's proof
for example, or anything else. Also, adjust the space above and below, if you want.
\begin{claim}
foo
\end{claim}
\begin{claimproof}
foo
\end{claimproof}
ps: Following the suggestion by @barbara beeton, to avoid new lines before the black square, replace the last pair of {}
by
{\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill\quad\hbox{$\blacksquare$}}
Best Answer
Define a new module
There may be other (easier) ways, but you can create a new module, based on the existing one. It's not a lot of work, you just have to copy and rename some files, then do some small modifications to them:
Go to the LyX system directory, and from the layouts folder copy the two files
theorems-ams.module
andtheorems-ams.inc
, and paste them into the LyX user directory. (To find the path to these two directories, open LyX and do Help --> About LyX.)Rename both files in the User directory, to for example
theorems-ams-new.module
andtheorems-ams-new.inc
. Doesn't matter what the filename is, just something other than the original.Open the
theorems-ams-new.module
and make two changes:In the first line, change the name of the module, i.e. from
to
Further down, change
to
I.e., the filename should be same as the other file you just renamed.
Open
theorems-ams-new.inc
, and find the definition of the Claim environment (lines 257-271, in my version). There are two changes you should make.In the second line of the definition, change the
CopyStyle
fromRemark
toTheorem
(optionallyDefinition
, see below). This defines how it is rendered in LyX.In the sixth line of the definition, change
to
This changes how it is rendered in the PDF. The
plain
style typesets the 'heading' in bold font, and the body in italics, just like theorems. If you wish to have the body of theclaim
in roman font, use\theoremstyle{definition}
instead. In this case you would probably also like to useCopyStyle Definition
, as mentioned above.Having done these modifications, you may need to reconfigure (Tools --> Reconfigure) and restart LyX. Now, instead of loading the 'Theorems (AMS)' module, load your own 'Theorems (AMS) modified'.
Using Local layout.
If this is a modification you need for just a single document, you can use Document --> Settings --> Local layout instead. Copy the entire definition of Claim to the Local layout, and do the changes described in point 4 above.