使用 AMS 環境匯入和匯出 LyX 文件

使用 AMS 環境匯入和匯出 LyX 文件

我在 .lyx 格式和 .tex 格式之間來回轉換使用 AMS 環境的 LyX 檔案時遇到一些問題。為了明白我的意思,這裡有一個最小的例子。

從以下原始 LyX 檔案開始:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\begin_modules
theorems-ams-bytype
theorems-sec-bytype
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "charter" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize 12
\spacing single
\use_hyperref false
\papersize letterpaper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 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
\leftmargin 0.5in
\topmargin 0.75in
\rightmargin 0.5in
\bottommargin 0.75in
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip bigskip
\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 Definition
Sample Text.
\end_layout

\end_body
\end_document

我使用“檔案”>“匯出”>“LaTeX”(普通)產生以下 .tex 檔案:

%% LyX 2.2.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,english]{article}
\usepackage{charter}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=0.75in,bmargin=0.75in,lmargin=0.5in,rmargin=0.5in}
\setlength{\parskip}{\bigskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{amsthm}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
  \theoremstyle{definition}
  \newtheorem{defn}{\protect\definitionname}[section]

\makeatother

\usepackage{babel}
  \providecommand{\definitionname}{Definition}

\begin{document}
\begin{defn}
Sample Text.
\end{defn}

\end{document}

到目前為止,一切順利,因為兩個檔案都編譯為同一個 .pdf 檔案。不幸的是,當我嘗試將 .tex 檔案匯入回 LyX 時,AMS 環境消失了,我只剩下一些 ERT:

在此輸入影像描述

當嘗試在 LyX 中編譯時,我收到錯誤:

! LaTeX Error: Environment defn undefined.

看起來在匯入過程中,以下行已被刪除:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
  \theoremstyle{definition}
  \newtheorem{defn}{\protect\definitionname}[section]

嘗試將此程式碼黏回前導碼會導致「未定義的控制序列」錯誤。

這是 LyX 2.2.3 預期的行為還是我在這裡錯過了一些東西?如果可能的話,我想在整個轉換過程中保留所有 AMS 環境。

先致謝!

相關內容