lyx无法识别包含的命令(dsfont)

时间:2015-03-25 17:07:27

标签: latex lyx

我正在使用lyx并希望使用LaTeX软件包dsfont来显示双笔划的单位矩阵。所以,我把

 \usepackage{dsfont}

在我的文件序言中并加上

\mathds{1}

在我的等式中。但是,lyx无法识别文档中的命令,因此只需以红色打印\mathds即可。当我编译文档时,lyx不会抱怨不知道该命令。但是,在生成的pdf中,我只看到" {1}"在我的公式中。 如果我查看我通过导出到tex生成的tex文档,lyx实际上将以下代码放在文档中:

\mathds \{1\}

知道这里有什么问题吗?

2 个答案:

答案 0 :(得分:2)

问题是LyX在数学方面不支持ERT(我认为有人在研究这个问题)。您可以通过定义数学宏(Insert> Math> Macro)来解决此问题。

这是LyX显示(您可以在宏中自定义):

enter image description here

这是输出:

enter image description here

以下是生成的文件:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{dsfont}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\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_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\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 Standard
\begin_inset FormulaMacro
\newcommand{\mds}[1]{\mathds{#1}}
{MDS\{#1\}}
\end_inset


\end_layout

\begin_layout Standard
\begin_inset Formula $\mds 1$
\end_inset


\end_layout

\end_body
\end_document

生成的.tex文件(从LyX导出):

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{dsfont}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\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_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\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 Standard
\begin_inset FormulaMacro
\newcommand{\mds}[1]{\mathds{#1}}
{MDS\{#1\}}
\end_inset


\end_layout

\begin_layout Standard
\begin_inset Formula $\mds 1$
\end_inset


\end_layout

\end_body
\end_document

答案 1 :(得分:0)

假设我想多次使用它,我为此制作了一个简单的模块。它将\mathbb重新定义为\mathds

只需将以下内容复制到文本文件中,然后将其保存到用户布局文件夹中(请参阅帮助>关于中的位置)。重新配置LyX并在文档设置中激活它。

#\DeclareLyXModule{DS-Font}
#DescriptionBegin
# If you like the DS font, just include this package. It should be compatible with any other package.
# It defines \mathbb to be \mathds and maps the original \mathbb to \mathbbOld
#DescriptionEnd
#
#Author: Quirin F. Schroll  aka.  Bolpat

Format 60

AddToPreamble
    \usepackage{dsfont}
    \newcommand{\mathbbOld}{\mathbb}
    \renewcommand{\mathbb}{\mathds}
EndPreamble