Lyx 2.0 定理/引理/主张环境的格式化引用

Lyx 2.0 定理/引理/主张环境的格式化引用

在 Lyx 2.0 中,我尝试使用格式化的引用来引用权利要求,但无法获取“格式化”部分,即我无法排版“权利要求”以及权利要求编号。

我正在使用模块“定理(按类型编号)”和“定理(按章节内类型编号)”。我在“声明”环境中有一个段落,带有标签“声明:1”。(我通过编辑获得了“声明:”部分../Resources/layouts/theorems-refprefix.inc,但在进行此更改之前,我的行为相同。)后来我放入了一个格式化的引用,它生成 tex 代码为“ \claimref{1}”。这在输出中排版为“... 1.1 ...”,即只有章节和声明计数器编号。我希望看到的是“... 声明 1.1 ...”

如果我将这些声明更改为定理环境并删除并重新制作标签(因此“thm:1”)并更新引用,格式化的引用将根据需要为引用排版单词“定理”。引理似乎不起作用(尽管我可能没有重新制作所有标签。)

我确实看到 Lyx 将此内容添加到序言中:

\AtBeginDocument{\providecommand\claimref[1]{\ref{claim:#1}}}

我也看到了

\RS@ifundefined{thmref}
  {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}}
  {}

我无法追溯其起源,但它也许可以解释该定理为何有效。

有任何想法吗?

答案1

添加到文档前言(文档-->设置-->LaTeX前言)

\newref{claim}{name=claim~}

并且它可能会起作用。正如 egreg 在评论中提到的那样,refstyle包被使用,你必须告诉它应该插入什么以 开头的标签claim:

refstyle还提供了句首引用(大写字母)和复数形式的命令,并且可以指定在这些情况下要插入的单词,例如

\newref{claim}{name=claim~,Name=Claim~,names=claims~,Names=Claims~}

但是,除了使用 ERT(例如),我不知道如何让 LyX 使用这些\Claimref{claim:1}。请参阅refstyle文档了解详情。

例子

将以下代码复制到一个空文件并另存为.lyx文件,例如example.lyx。在 LyX 中打开并编译。下面是 LyX 视图和 PDF 的屏幕截图。

#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

在此处输入图片描述 在此处输入图片描述

答案2

根据 LyX 手册,首先确保检查Use refstyle (not prettyref) ...- Document> Settings-> Document Class,并且您可以在序言中放入以下内容:

\newref{claim}{refcmd={claim \ref{#1}}}

然后,无论何时引用以选项开头的标签claim:Formatted reference您都会获得所需的格式。

我擅自修改了示例 lyx 文件:

#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}{refcmd={claim \ref{#1}}}
\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:1"

\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:1"

\end_inset

.
\end_layout

\end_body
\end_document

相关内容