Importando e exportando arquivos LyX com ambientes AMS

Importando e exportando arquivos LyX com ambientes AMS

Estou tendo problemas para converter arquivos LyX que usam ambientes AMS entre o formato .lyx e o formato .tex. Para entender o que quero dizer, aqui está um exemplo mínimo.

Começando com o seguinte arquivo LyX bruto:

#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

Usei File > Export > LaTeX (plain) para gerar o seguinte arquivo .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}

Até agora, tudo bem, já que ambos os arquivos são compilados no mesmo arquivo .pdf. Infelizmente, quando tento importar o arquivo .tex de volta para o LyX, o ambiente AMS desaparece e fico com algum ERT:

insira a descrição da imagem aqui

E ao tentar compilar no LyX, recebo o erro:

! LaTeX Error: Environment defn undefined.

Parece que durante o processo de importação as seguintes linhas foram removidas:

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

Tentar inserir esse código de volta no preâmbulo resulta em um erro de 'Sequência de controle indefinida'.

Esse comportamento é esperado para LyX 2.2.3 ou perdi alguma coisa aqui? Se possível, gostaria de preservar todos os ambientes AMS durante todo o processo de conversão.

Desde já, obrigado!

informação relacionada