From: Uwe Stöhr Date: Sun, 17 Feb 2013 02:15:24 +0000 (+0100) Subject: tex2lyx/Preamble.cpp: proper handling of the refstyle preamble code X-Git-Tag: 2.1.0beta1~682 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a99241266b1ad0cefd0f96a95b9793c9617df4ca;p=features.git tex2lyx/Preamble.cpp: proper handling of the refstyle preamble code - also rename the test file because it is also an excellent test file for the theorem environments - which are not yet supported by tex2lyx --- diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 7e902c6c7e..fead3b167e 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -1370,6 +1370,66 @@ void Preamble::parse(Parser & p, string const & forceclass, p.setCatcode('@', catOther); } + else if (t.cs() == "RS@ifundefined") { + string const name = p.verbatim_item(); + string const body1 = p.verbatim_item(); + string const body2 = p.verbatim_item(); + // store the in_lyx_preamble setting + bool const was_in_lyx_preamble = in_lyx_preamble; + if (name == "subref" + || name == "thmref" + || name == "lemref") { + p.skip_spaces(); + preamble.registerAutomaticallyLoadedPackage("refstyle"); + in_lyx_preamble = true; + } + // only non-lyxspecific stuff + if (!in_lyx_preamble) { + ostringstream ss; + ss << '\\' << t.cs(); + ss << '{' << name << '}' + << '{' << body1 << '}' + << '{' << body2 << '}'; + h_preamble << ss.str(); + } + // restore the in_lyx_preamble setting + in_lyx_preamble = was_in_lyx_preamble; + } + + else if (t.cs() == "AtBeginDocument") { + string const name = p.verbatim_item(); + // store the in_lyx_preamble setting + bool const was_in_lyx_preamble = in_lyx_preamble; + if (name == "\\providecommand\\partref[1]{\\ref{part:#1}}" + || name == "\\providecommand\\chapref[1]{\\ref{chap:#1}}" + || name == "\\providecommand\\secref[1]{\\ref{sec:#1}}" + || name == "\\providecommand\\subref[1]{\\ref{sub:#1}}" + || name == "\\providecommand\\parref[1]{\\ref{par:#1}}" + || name == "\\providecommand\\figref[1]{\\ref{fig:#1}}" + || name == "\\providecommand\\tabref[1]{\\ref{tab:#1}}" + || name == "\\providecommand\\algref[1]{\\ref{alg:#1}}" + || name == "\\providecommand\\fnref[1]{\\ref{fn:#1}}" + || name == "\\providecommand\\enuref[1]{\\ref{enu:#1}}" + || name == "\\providecommand\\eqref[1]{\\ref{eq:#1}}" + || name == "\\providecommand\\lemref[1]{\\ref{lem:#1}}" + || name == "\\providecommand\\thmref[1]{\\ref{thm:#1}}" + || name == "\\providecommand\\corref[1]{\\ref{cor:#1}}" + || name == "\\providecommand\\propref[1]{\\ref{prop:#1}}") { + p.skip_spaces(); + preamble.registerAutomaticallyLoadedPackage("refstyle"); + in_lyx_preamble = true; + } + // only non-lyxspecific stuff + if (!in_lyx_preamble) { + ostringstream ss; + ss << '\\' << t.cs(); + ss << '{' << name << '}'; + h_preamble << ss.str(); + } + // restore the in_lyx_preamble setting + in_lyx_preamble = was_in_lyx_preamble; + } + else if (t.cs() == "newcommand" || t.cs() == "newcommandx" || t.cs() == "renewcommand" || t.cs() == "renewcommandx" || t.cs() == "providecommand" || t.cs() == "providecommandx" @@ -1414,7 +1474,6 @@ void Preamble::parse(Parser & p, string const & forceclass, p.skip_spaces(); in_lyx_preamble = true; } - if (name == "\\bfdefault") // LyX re-adds this if a kurier font is used if (is_known(h_font_sans, known_kurier_fonts) && body == "b") { diff --git a/src/tex2lyx/test/test-refstyle-references.lyx.lyx b/src/tex2lyx/test/test-refstyle-references.lyx.lyx deleted file mode 100644 index 06075ab85e..0000000000 --- a/src/tex2lyx/test/test-refstyle-references.lyx.lyx +++ /dev/null @@ -1,873 +0,0 @@ -#LyX file created by tex2lyx 2.1.0dev -\lyxformat 461 -\begin_document -\begin_header -\textclass book -\begin_preamble -\usepackage{refstyle} - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. - -\AtBeginDocument{\providecommand{\partref}[1]{\ref{part:#1}}} -\AtBeginDocument{\providecommand{\chapref}[1]{\ref{chap:#1}}} -\AtBeginDocument{\providecommand{\secref}[1]{\ref{sec:#1}}} -\AtBeginDocument{\providecommand{\subref}[1]{\ref{sub:#1}}} -\AtBeginDocument{\providecommand{\parref}[1]{\ref{par:#1}}} -\AtBeginDocument{\providecommand{\figref}[1]{\ref{fig:#1}}} -\AtBeginDocument{\providecommand{\tabref}[1]{\ref{tab:#1}}} -\AtBeginDocument{\providecommand{\algref}[1]{\ref{alg:#1}}} -\AtBeginDocument{\providecommand{\fnref}[1]{\ref{fn:#1}}} -\AtBeginDocument{\providecommand{\enuref}[1]{\ref{enu:#1}}} -\AtBeginDocument{\providecommand{\eqref}[1]{\ref{eq:#1}}} -\AtBeginDocument{\providecommand{\lemref}[1]{\ref{lem:#1}}} -\AtBeginDocument{\providecommand{\thmref}[1]{\ref{thm:#1}}} -\AtBeginDocument{\providecommand{\corref}[1]{\ref{cor:#1}}} -\AtBeginDocument{\providecommand{\propref}[1]{\ref{prop:#1}}} -\floatstyle{ruled} -\newfloat{algorithm}{tbp}{loa}[chapter] -\providecommand{\algorithmname}{Algorithm} -\floatname{algorithm}{\protect\algorithmname} -\RS@ifundefined{subref} - {\def\RSsubtxt{section~}\newref{sub}{name = \RSsubtxt}} - {} -\RS@ifundefined{thmref} - {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}} - {} -\RS@ifundefined{lemref} - {\def\RSlemtxt{lemma~}\newref{lem}{name = \RSlemtxt}} - {} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. -\theoremstyle{plain} -\newtheorem{thm}{}\theoremstyle{plain} -\newtheorem{lem}[thm]{}\theoremstyle{plain} -\newtheorem{cor}[thm]{}\theoremstyle{plain} -\newtheorem{prop}[thm]{}\theoremstyle{plain} -\newtheorem{conjecture}[thm]{}\theoremstyle{plain} -\newtheorem{fact}[thm]{}\theoremstyle{definition} -\newtheorem{defn}[thm]{}\theoremstyle{definition} -\newtheorem{example}[thm]{}\theoremstyle{definition} -\newtheorem{problem}[thm]{}\theoremstyle{definition} -\newtheorem{xca}[thm]{}\theoremstyle{remark} -\newtheorem{rem}[thm]{}\theoremstyle{remark} -\newtheorem{claim}[thm]{}\ifx\proof\undefined -\newenvironment{proof}[1][\protect\proofname]{\par -\normalfont\topsep6\p@\@plus6\p@\relax -\trivlist -\itemindent\parindent -\item[\hskip\labelsep\scshape #1]\ignorespaces -}{% -\endtrivlist\@endpefalse -} -\providecommand{\proofname}{Proof} -\fi - - - -\usepackage{babel} -\providecommand{\claimname}{Claim} -\providecommand{\conjecturename}{Conjecture} -\providecommand{\corollaryname}{Corollary} -\providecommand{\definitionname}{Definition} -\providecommand{\examplename}{Example} -\providecommand{\exercisename}{Exercise} -\providecommand{\factname}{Fact} -\providecommand{\lemmaname}{Lemma} -\providecommand{\problemname}{Problem} -\providecommand{\propositionname}{Proposition} -\providecommand{\remarkname}{Remark} -\providecommand{\theoremname}{Theorem} - - -\end_preamble -\use_default_options false -\begin_modules -theorems-ams -\end_modules -\maintain_unincluded_children false -\language english -\language_package default -\inputencoding latin9 -\fontencoding T1 -\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 0 -\use_package esint 1 -\use_package mathdots 0 -\use_package mathtools 0 -\use_package mhchem 0 -\use_package stackrel 0 -\use_package stmaryrd 0 -\use_package undertilde 0 -\cite_engine basic -\cite_engine_type numerical -\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 2 -\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 Part -part -\begin_inset CommandInset label -LatexCommand label -name "part:part" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "part:part" - -\end_inset - - -\end_layout - -\begin_layout Chapter -chapter -\begin_inset CommandInset label -LatexCommand label -name "chap:chapter" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "chap:chapter" - -\end_inset - - -\end_layout - -\begin_layout Section -Section -\begin_inset CommandInset label -LatexCommand label -name "sec:Section" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "sec:Section" - -\end_inset - - -\end_layout - -\begin_layout Subsection -Subsection -\begin_inset CommandInset label -LatexCommand label -name "sub:subsection" - -\end_inset - - -\end_layout - -\begin_layout Standard -Ref to -\begin_inset CommandInset ref -LatexCommand formatted -reference "sub:subsection" - -\end_inset - -. -\end_layout - -\begin_layout Subsubsection -Subsubsection -\begin_inset CommandInset label -LatexCommand label -name "sub:Subsubsection" - -\end_inset - - -\end_layout - -\begin_layout Standard -Ref to -\begin_inset CommandInset ref -LatexCommand formatted -reference "sub:Subsubsection" - -\end_inset - -. -\end_layout - -\begin_layout Paragraph -paragraph -\begin_inset CommandInset label -LatexCommand label -name "par:paragraph" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "par:paragraph" - -\end_inset - - -\end_layout - -\begin_layout Subparagraph -subparagraph -\begin_inset CommandInset label -LatexCommand label -name "par:subparagraph" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "par:subparagraph" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Float figure -wide false -sideways false -status open - - -\begin_layout Standard - -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -\backslash -protect -\end_layout - -\end_inset - - -\begin_inset Caption Standard - -\begin_layout Standard -figure -\begin_inset CommandInset label -LatexCommand label -name "fig:figure" - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "fig:figure" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Float table -wide false -sideways false -status open - - -\begin_layout Standard - -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -\backslash -protect -\end_layout - -\end_inset - - -\begin_inset Caption Standard - -\begin_layout Standard -table -\begin_inset CommandInset label -LatexCommand label -name "tab:table" - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "tab:table" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Float algorithm -wide false -sideways false -status open - - -\begin_layout Standard - -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -\backslash -protect -\end_layout - -\end_inset - - -\begin_inset Caption Standard - -\begin_layout Standard -algorithm -\begin_inset CommandInset label -LatexCommand label -name "alg:algorithm" - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "alg:algorithm" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Foot -status collapsed - - -\begin_layout Standard -foot -\begin_inset CommandInset label -LatexCommand label -name "fn:foot" - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "fn:foot" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Marginal -status collapsed - - -\begin_layout Standard -margin -\begin_inset CommandInset label -LatexCommand label -name "margin" - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand ref -reference "margin" - -\end_inset - - -\end_layout - -\begin_layout Enumerate -item -\begin_inset CommandInset label -LatexCommand label -name "enu:item" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "enu:item" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset Formula \begin{equation} -A=B\label{eq:A=00003DB} -\end{equation} -\end_inset - - -\end_layout - -\begin_layout Standard - -\begin_inset CommandInset ref -LatexCommand formatted -reference "eq:A=00003DB" - -\end_inset - - -\end_layout - -\begin_layout Lemma -lemma -\begin_inset CommandInset label -LatexCommand label -name "lem:lemma" - -\end_inset - - -\end_layout - -\begin_layout Lemma - -\begin_inset CommandInset ref -LatexCommand formatted -reference "lem:lemma" - -\end_inset - - -\end_layout - -\begin_layout Theorem -theorem -\begin_inset CommandInset label -LatexCommand label -name "thm:theorem" - -\end_inset - - -\end_layout - -\begin_layout Theorem - -\begin_inset CommandInset ref -LatexCommand formatted -reference "thm:theorem" - -\end_inset - - -\end_layout - -\begin_layout Corollary -corollary -\begin_inset CommandInset label -LatexCommand label -name "cor:corollary" - -\end_inset - - -\end_layout - -\begin_layout Corollary - -\begin_inset CommandInset ref -LatexCommand formatted -reference "cor:corollary" - -\end_inset - - -\end_layout - -\begin_layout Proposition -proposition -\begin_inset CommandInset label -LatexCommand label -name "prop:proposition" - -\end_inset - - -\end_layout - -\begin_layout Proposition - -\begin_inset CommandInset ref -LatexCommand formatted -reference "prop:proposition" - -\end_inset - - -\end_layout - -\begin_layout Conjecture -conjecture -\begin_inset CommandInset label -LatexCommand label -name "conjecture" - -\end_inset - - -\end_layout - -\begin_layout Conjecture - -\begin_inset CommandInset ref -LatexCommand ref -reference "conjecture" - -\end_inset - - -\end_layout - -\begin_layout Fact -fact -\begin_inset CommandInset label -LatexCommand label -name "fact" - -\end_inset - - -\end_layout - -\begin_layout Fact - -\begin_inset CommandInset ref -LatexCommand ref -reference "fact" - -\end_inset - - -\end_layout - -\begin_layout Definition -definition -\begin_inset CommandInset label -LatexCommand label -name "definition" - -\end_inset - - -\end_layout - -\begin_layout Definition - -\begin_inset CommandInset ref -LatexCommand ref -reference "definition" - -\end_inset - - -\end_layout - -\begin_layout Example -example -\begin_inset CommandInset label -LatexCommand label -name "example" - -\end_inset - - -\end_layout - -\begin_layout Example - -\begin_inset CommandInset ref -LatexCommand ref -reference "example" - -\end_inset - - -\end_layout - -\begin_layout Problem -problem -\begin_inset CommandInset label -LatexCommand label -name "problem" - -\end_inset - - -\end_layout - -\begin_layout Problem - -\begin_inset CommandInset ref -LatexCommand ref -reference "problem" - -\end_inset - - -\end_layout - -\begin_layout Exercise -exercise -\begin_inset CommandInset label -LatexCommand label -name "exercise" - -\end_inset - - -\end_layout - -\begin_layout Exercise - -\begin_inset CommandInset ref -LatexCommand ref -reference "exercise" - -\end_inset - - -\end_layout - -\begin_layout Remark -remark -\begin_inset CommandInset label -LatexCommand label -name "remark" - -\end_inset - - -\end_layout - -\begin_layout Remark - -\begin_inset CommandInset ref -LatexCommand ref -reference "remark" - -\end_inset - - -\end_layout - -\begin_layout Claim -claim -\begin_inset CommandInset label -LatexCommand label -name "claim" - -\end_inset - - -\end_layout - -\begin_layout Claim - -\begin_inset CommandInset ref -LatexCommand ref -reference "claim" - -\end_inset - - -\end_layout - -\begin_layout Proof -proof -\begin_inset CommandInset label -LatexCommand label -name "proof" - -\end_inset - - -\end_layout - -\begin_layout Proof - -\begin_inset CommandInset ref -LatexCommand ref -reference "proof" - -\end_inset - - -\end_layout - -\end_body -\end_document diff --git a/src/tex2lyx/test/test-refstyle-references.tex b/src/tex2lyx/test/test-refstyle-references.tex deleted file mode 100644 index 70ad4c6501..0000000000 --- a/src/tex2lyx/test/test-refstyle-references.tex +++ /dev/null @@ -1,224 +0,0 @@ -\documentclass[english]{book} -\usepackage[T1]{fontenc} -\usepackage[latin9]{inputenc} -\usepackage{refstyle} -\usepackage{float} -\usepackage{amsthm} - -\makeatletter - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. - -\AtBeginDocument{\providecommand\partref[1]{\ref{part:#1}}} -\AtBeginDocument{\providecommand\chapref[1]{\ref{chap:#1}}} -\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}} -\AtBeginDocument{\providecommand\subref[1]{\ref{sub:#1}}} -\AtBeginDocument{\providecommand\parref[1]{\ref{par:#1}}} -\AtBeginDocument{\providecommand\figref[1]{\ref{fig:#1}}} -\AtBeginDocument{\providecommand\tabref[1]{\ref{tab:#1}}} -\AtBeginDocument{\providecommand\algref[1]{\ref{alg:#1}}} -\AtBeginDocument{\providecommand\fnref[1]{\ref{fn:#1}}} -\AtBeginDocument{\providecommand\enuref[1]{\ref{enu:#1}}} -\AtBeginDocument{\providecommand\eqref[1]{\ref{eq:#1}}} -\AtBeginDocument{\providecommand\lemref[1]{\ref{lem:#1}}} -\AtBeginDocument{\providecommand\thmref[1]{\ref{thm:#1}}} -\AtBeginDocument{\providecommand\corref[1]{\ref{cor:#1}}} -\AtBeginDocument{\providecommand\propref[1]{\ref{prop:#1}}} -\floatstyle{ruled} -\newfloat{algorithm}{tbp}{loa}[chapter] -\providecommand{\algorithmname}{Algorithm} -\floatname{algorithm}{\protect\algorithmname} -\RS@ifundefined{subref} - {\def\RSsubtxt{section~}\newref{sub}{name = \RSsubtxt}} - {} -\RS@ifundefined{thmref} - {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}} - {} -\RS@ifundefined{lemref} - {\def\RSlemtxt{lemma~}\newref{lem}{name = \RSlemtxt}} - {} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. -\theoremstyle{plain} -\newtheorem{thm}{\protect\theoremname} -\theoremstyle{plain} -\newtheorem{lem}[thm]{\protect\lemmaname} -\theoremstyle{plain} -\newtheorem{cor}[thm]{\protect\corollaryname} -\theoremstyle{plain} -\newtheorem{prop}[thm]{\protect\propositionname} -\theoremstyle{plain} -\newtheorem{conjecture}[thm]{\protect\conjecturename} -\theoremstyle{plain} -\newtheorem{fact}[thm]{\protect\factname} -\theoremstyle{definition} -\newtheorem{defn}[thm]{\protect\definitionname} -\theoremstyle{definition} -\newtheorem{example}[thm]{\protect\examplename} -\theoremstyle{definition} -\newtheorem{problem}[thm]{\protect\problemname} -\theoremstyle{definition} -\newtheorem{xca}[thm]{\protect\exercisename} -\theoremstyle{remark} -\newtheorem{rem}[thm]{\protect\remarkname} -\theoremstyle{remark} -\newtheorem{claim}[thm]{\protect\claimname} -\ifx\proof\undefined -\newenvironment{proof}[1][\protect\proofname]{\par -\normalfont\topsep6\p@\@plus6\p@\relax -\trivlist -\itemindent\parindent -\item[\hskip\labelsep\scshape #1]\ignorespaces -}{% -\endtrivlist\@endpefalse -} -\providecommand{\proofname}{Proof} -\fi - -\makeatother - -\usepackage{babel} -\providecommand{\claimname}{Claim} -\providecommand{\conjecturename}{Conjecture} -\providecommand{\corollaryname}{Corollary} -\providecommand{\definitionname}{Definition} -\providecommand{\examplename}{Example} -\providecommand{\exercisename}{Exercise} -\providecommand{\factname}{Fact} -\providecommand{\lemmaname}{Lemma} -\providecommand{\problemname}{Problem} -\providecommand{\propositionname}{Proposition} -\providecommand{\remarkname}{Remark} -\providecommand{\theoremname}{Theorem} - -\begin{document} - -\part{part\label{part:part}} - -\partref{part} - - -\chapter{chapter\label{chap:chapter}} - -\chapref{chapter} - - -\section{Section\label{sec:Section}} - -\secref{Section} - - -\subsection{Subsection\label{sub:subsection}} - -Ref to \subref{subsection}. - - -\subsubsection{Subsubsection\label{sub:Subsubsection}} - -Ref to \subref{Subsubsection}. - - -\paragraph{paragraph\label{par:paragraph}} - -\parref{paragraph} - - -\subparagraph{subparagraph\label{par:subparagraph}} - -\parref{subparagraph} - -\begin{figure} -\protect\caption{figure\label{fig:figure}} -\end{figure} - - -\figref{figure} - -\begin{table} -\protect\caption{table\label{tab:table}} -\end{table} - - -\tabref{table} - -\begin{algorithm} -\protect\caption{algorithm\label{alg:algorithm}} -\end{algorithm} - - -\algref{algorithm} - -\footnote{foot\label{fn:foot}% -} - -\fnref{foot} - -\marginpar{margin\label{margin}} - -\ref{margin} -\begin{enumerate} -\item item\label{enu:item} -\end{enumerate} -\enuref{item} - -\begin{equation} -A=B\label{eq:A=00003DB} -\end{equation} - - -\eqref{A=00003DB} -\begin{lem} -lemma\label{lem:lemma} - -\lemref{lemma}\end{lem} -\begin{thm} -theorem\label{thm:theorem} - -\thmref{theorem}\end{thm} -\begin{cor} -corollary\label{cor:corollary} - -\corref{corollary}\end{cor} -\begin{prop} -proposition\label{prop:proposition} - -\propref{proposition}\end{prop} -\begin{conjecture} -conjecture\label{conjecture} - -\ref{conjecture}\end{conjecture} -\begin{fact} -fact\label{fact} - -\ref{fact}\end{fact} -\begin{defn} -definition\label{definition} - -\ref{definition}\end{defn} -\begin{example} -example\label{example} - -\ref{example}\end{example} -\begin{problem} -problem\label{problem} - -\ref{problem}\end{problem} -\begin{xca} -exercise\label{exercise} - -\ref{exercise}\end{xca} -\begin{rem} -remark\label{remark} - -\ref{remark}\end{rem} -\begin{claim} -claim\label{claim} - -\ref{claim}\end{claim} -\begin{proof} -proof\label{proof} - -\ref{proof}\end{proof} - -\end{document} diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx new file mode 100644 index 0000000000..d6411a6265 --- /dev/null +++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx @@ -0,0 +1,849 @@ +#LyX file created by tex2lyx 2.1.0dev +\lyxformat 462 +\begin_document +\begin_header +\textclass book +\begin_preamble + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. + +\floatstyle{ruled} +\newfloat{algorithm}{tbp}{loa}[chapter] +\providecommand{\algorithmname}{Algorithm} +\floatname{algorithm}{\protect\algorithmname} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. +\theoremstyle{plain} +\newtheorem{thm}{}\theoremstyle{plain} +\newtheorem{lem}[thm]{}\theoremstyle{plain} +\newtheorem{cor}[thm]{}\theoremstyle{plain} +\newtheorem{prop}[thm]{}\theoremstyle{plain} +\newtheorem{conjecture}[thm]{}\theoremstyle{plain} +\newtheorem{fact}[thm]{}\theoremstyle{definition} +\newtheorem{defn}[thm]{}\theoremstyle{definition} +\newtheorem{example}[thm]{}\theoremstyle{definition} +\newtheorem{problem}[thm]{}\theoremstyle{definition} +\newtheorem{xca}[thm]{}\theoremstyle{remark} +\newtheorem{rem}[thm]{}\theoremstyle{remark} +\newtheorem{claim}[thm]{}\ifx\proof\undefined +\newenvironment{proof}[1][\protect\proofname]{\par +\normalfont\topsep6\p@\@plus6\p@\relax +\trivlist +\itemindent\parindent +\item[\hskip\labelsep\scshape #1]\ignorespaces +}{% +\endtrivlist\@endpefalse +} +\providecommand{\proofname}{Proof} +\fi + + + +\usepackage{babel} +\providecommand{\claimname}{Claim} +\providecommand{\conjecturename}{Conjecture} +\providecommand{\corollaryname}{Corollary} +\providecommand{\definitionname}{Definition} +\providecommand{\examplename}{Example} +\providecommand{\exercisename}{Exercise} +\providecommand{\factname}{Fact} +\providecommand{\lemmaname}{Lemma} +\providecommand{\problemname}{Problem} +\providecommand{\propositionname}{Proposition} +\providecommand{\remarkname}{Remark} +\providecommand{\theoremname}{Theorem} + + +\end_preamble +\use_default_options false +\begin_modules +theorems-ams +\end_modules +\maintain_unincluded_children false +\language english +\language_package default +\inputencoding latin9 +\fontencoding T1 +\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 0 +\use_package esint 1 +\use_package mathdots 0 +\use_package mathtools 0 +\use_package mhchem 0 +\use_package stackrel 0 +\use_package stmaryrd 0 +\use_package undertilde 0 +\cite_engine basic +\cite_engine_type numerical +\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 2 +\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 Part +part +\begin_inset CommandInset label +LatexCommand label +name "part:part" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "part:part" + +\end_inset + + +\end_layout + +\begin_layout Chapter +chapter +\begin_inset CommandInset label +LatexCommand label +name "chap:chapter" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "chap:chapter" + +\end_inset + + +\end_layout + +\begin_layout Section +Section +\begin_inset CommandInset label +LatexCommand label +name "sec:Section" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "sec:Section" + +\end_inset + + +\end_layout + +\begin_layout Subsection +Subsection +\begin_inset CommandInset label +LatexCommand label +name "sub:subsection" + +\end_inset + + +\end_layout + +\begin_layout Standard +Ref to +\begin_inset CommandInset ref +LatexCommand formatted +reference "sub:subsection" + +\end_inset + +. +\end_layout + +\begin_layout Subsubsection +Subsubsection +\begin_inset CommandInset label +LatexCommand label +name "sub:Subsubsection" + +\end_inset + + +\end_layout + +\begin_layout Standard +Ref to +\begin_inset CommandInset ref +LatexCommand formatted +reference "sub:Subsubsection" + +\end_inset + +. +\end_layout + +\begin_layout Paragraph +paragraph +\begin_inset CommandInset label +LatexCommand label +name "par:paragraph" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "par:paragraph" + +\end_inset + + +\end_layout + +\begin_layout Subparagraph +subparagraph +\begin_inset CommandInset label +LatexCommand label +name "par:subparagraph" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "par:subparagraph" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Float figure +wide false +sideways false +status open + + +\begin_layout Standard + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +protect +\end_layout + +\end_inset + + +\begin_inset Caption Standard + +\begin_layout Standard +figure +\begin_inset CommandInset label +LatexCommand label +name "fig:figure" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "fig:figure" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Float table +wide false +sideways false +status open + + +\begin_layout Standard + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +protect +\end_layout + +\end_inset + + +\begin_inset Caption Standard + +\begin_layout Standard +table +\begin_inset CommandInset label +LatexCommand label +name "tab:table" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "tab:table" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Float algorithm +wide false +sideways false +status open + + +\begin_layout Standard + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +protect +\end_layout + +\end_inset + + +\begin_inset Caption Standard + +\begin_layout Standard +algorithm +\begin_inset CommandInset label +LatexCommand label +name "alg:algorithm" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "alg:algorithm" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Foot +status collapsed + + +\begin_layout Standard +foot +\begin_inset CommandInset label +LatexCommand label +name "fn:foot" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "fn:foot" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Marginal +status collapsed + + +\begin_layout Standard +margin +\begin_inset CommandInset label +LatexCommand label +name "margin" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand ref +reference "margin" + +\end_inset + + +\end_layout + +\begin_layout Enumerate +item +\begin_inset CommandInset label +LatexCommand label +name "enu:item" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "enu:item" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset Formula \begin{equation} +A=B\label{eq:A=00003DB} +\end{equation} +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset CommandInset ref +LatexCommand formatted +reference "eq:A=00003DB" + +\end_inset + + +\end_layout + +\begin_layout Lemma +lemma +\begin_inset CommandInset label +LatexCommand label +name "lem:lemma" + +\end_inset + + +\end_layout + +\begin_layout Lemma + +\begin_inset CommandInset ref +LatexCommand formatted +reference "lem:lemma" + +\end_inset + + +\end_layout + +\begin_layout Theorem +theorem +\begin_inset CommandInset label +LatexCommand label +name "thm:theorem" + +\end_inset + + +\end_layout + +\begin_layout Theorem + +\begin_inset CommandInset ref +LatexCommand formatted +reference "thm:theorem" + +\end_inset + + +\end_layout + +\begin_layout Corollary +corollary +\begin_inset CommandInset label +LatexCommand label +name "cor:corollary" + +\end_inset + + +\end_layout + +\begin_layout Corollary + +\begin_inset CommandInset ref +LatexCommand formatted +reference "cor:corollary" + +\end_inset + + +\end_layout + +\begin_layout Proposition +proposition +\begin_inset CommandInset label +LatexCommand label +name "prop:proposition" + +\end_inset + + +\end_layout + +\begin_layout Proposition + +\begin_inset CommandInset ref +LatexCommand formatted +reference "prop:proposition" + +\end_inset + + +\end_layout + +\begin_layout Conjecture +conjecture +\begin_inset CommandInset label +LatexCommand label +name "conjecture" + +\end_inset + + +\end_layout + +\begin_layout Conjecture + +\begin_inset CommandInset ref +LatexCommand ref +reference "conjecture" + +\end_inset + + +\end_layout + +\begin_layout Fact +fact +\begin_inset CommandInset label +LatexCommand label +name "fact" + +\end_inset + + +\end_layout + +\begin_layout Fact + +\begin_inset CommandInset ref +LatexCommand ref +reference "fact" + +\end_inset + + +\end_layout + +\begin_layout Definition +definition +\begin_inset CommandInset label +LatexCommand label +name "definition" + +\end_inset + + +\end_layout + +\begin_layout Definition + +\begin_inset CommandInset ref +LatexCommand ref +reference "definition" + +\end_inset + + +\end_layout + +\begin_layout Example +example +\begin_inset CommandInset label +LatexCommand label +name "example" + +\end_inset + + +\end_layout + +\begin_layout Example + +\begin_inset CommandInset ref +LatexCommand ref +reference "example" + +\end_inset + + +\end_layout + +\begin_layout Problem +problem +\begin_inset CommandInset label +LatexCommand label +name "problem" + +\end_inset + + +\end_layout + +\begin_layout Problem + +\begin_inset CommandInset ref +LatexCommand ref +reference "problem" + +\end_inset + + +\end_layout + +\begin_layout Exercise +exercise +\begin_inset CommandInset label +LatexCommand label +name "exercise" + +\end_inset + + +\end_layout + +\begin_layout Exercise + +\begin_inset CommandInset ref +LatexCommand ref +reference "exercise" + +\end_inset + + +\end_layout + +\begin_layout Remark +remark +\begin_inset CommandInset label +LatexCommand label +name "remark" + +\end_inset + + +\end_layout + +\begin_layout Remark + +\begin_inset CommandInset ref +LatexCommand ref +reference "remark" + +\end_inset + + +\end_layout + +\begin_layout Claim +claim +\begin_inset CommandInset label +LatexCommand label +name "claim" + +\end_inset + + +\end_layout + +\begin_layout Claim + +\begin_inset CommandInset ref +LatexCommand ref +reference "claim" + +\end_inset + + +\end_layout + +\begin_layout Proof +proof +\begin_inset CommandInset label +LatexCommand label +name "proof" + +\end_inset + + +\end_layout + +\begin_layout Proof + +\begin_inset CommandInset ref +LatexCommand ref +reference "proof" + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/src/tex2lyx/test/test-refstyle-theorems.tex b/src/tex2lyx/test/test-refstyle-theorems.tex new file mode 100644 index 0000000000..70ad4c6501 --- /dev/null +++ b/src/tex2lyx/test/test-refstyle-theorems.tex @@ -0,0 +1,224 @@ +\documentclass[english]{book} +\usepackage[T1]{fontenc} +\usepackage[latin9]{inputenc} +\usepackage{refstyle} +\usepackage{float} +\usepackage{amsthm} + +\makeatletter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. + +\AtBeginDocument{\providecommand\partref[1]{\ref{part:#1}}} +\AtBeginDocument{\providecommand\chapref[1]{\ref{chap:#1}}} +\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}} +\AtBeginDocument{\providecommand\subref[1]{\ref{sub:#1}}} +\AtBeginDocument{\providecommand\parref[1]{\ref{par:#1}}} +\AtBeginDocument{\providecommand\figref[1]{\ref{fig:#1}}} +\AtBeginDocument{\providecommand\tabref[1]{\ref{tab:#1}}} +\AtBeginDocument{\providecommand\algref[1]{\ref{alg:#1}}} +\AtBeginDocument{\providecommand\fnref[1]{\ref{fn:#1}}} +\AtBeginDocument{\providecommand\enuref[1]{\ref{enu:#1}}} +\AtBeginDocument{\providecommand\eqref[1]{\ref{eq:#1}}} +\AtBeginDocument{\providecommand\lemref[1]{\ref{lem:#1}}} +\AtBeginDocument{\providecommand\thmref[1]{\ref{thm:#1}}} +\AtBeginDocument{\providecommand\corref[1]{\ref{cor:#1}}} +\AtBeginDocument{\providecommand\propref[1]{\ref{prop:#1}}} +\floatstyle{ruled} +\newfloat{algorithm}{tbp}{loa}[chapter] +\providecommand{\algorithmname}{Algorithm} +\floatname{algorithm}{\protect\algorithmname} +\RS@ifundefined{subref} + {\def\RSsubtxt{section~}\newref{sub}{name = \RSsubtxt}} + {} +\RS@ifundefined{thmref} + {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}} + {} +\RS@ifundefined{lemref} + {\def\RSlemtxt{lemma~}\newref{lem}{name = \RSlemtxt}} + {} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. +\theoremstyle{plain} +\newtheorem{thm}{\protect\theoremname} +\theoremstyle{plain} +\newtheorem{lem}[thm]{\protect\lemmaname} +\theoremstyle{plain} +\newtheorem{cor}[thm]{\protect\corollaryname} +\theoremstyle{plain} +\newtheorem{prop}[thm]{\protect\propositionname} +\theoremstyle{plain} +\newtheorem{conjecture}[thm]{\protect\conjecturename} +\theoremstyle{plain} +\newtheorem{fact}[thm]{\protect\factname} +\theoremstyle{definition} +\newtheorem{defn}[thm]{\protect\definitionname} +\theoremstyle{definition} +\newtheorem{example}[thm]{\protect\examplename} +\theoremstyle{definition} +\newtheorem{problem}[thm]{\protect\problemname} +\theoremstyle{definition} +\newtheorem{xca}[thm]{\protect\exercisename} +\theoremstyle{remark} +\newtheorem{rem}[thm]{\protect\remarkname} +\theoremstyle{remark} +\newtheorem{claim}[thm]{\protect\claimname} +\ifx\proof\undefined +\newenvironment{proof}[1][\protect\proofname]{\par +\normalfont\topsep6\p@\@plus6\p@\relax +\trivlist +\itemindent\parindent +\item[\hskip\labelsep\scshape #1]\ignorespaces +}{% +\endtrivlist\@endpefalse +} +\providecommand{\proofname}{Proof} +\fi + +\makeatother + +\usepackage{babel} +\providecommand{\claimname}{Claim} +\providecommand{\conjecturename}{Conjecture} +\providecommand{\corollaryname}{Corollary} +\providecommand{\definitionname}{Definition} +\providecommand{\examplename}{Example} +\providecommand{\exercisename}{Exercise} +\providecommand{\factname}{Fact} +\providecommand{\lemmaname}{Lemma} +\providecommand{\problemname}{Problem} +\providecommand{\propositionname}{Proposition} +\providecommand{\remarkname}{Remark} +\providecommand{\theoremname}{Theorem} + +\begin{document} + +\part{part\label{part:part}} + +\partref{part} + + +\chapter{chapter\label{chap:chapter}} + +\chapref{chapter} + + +\section{Section\label{sec:Section}} + +\secref{Section} + + +\subsection{Subsection\label{sub:subsection}} + +Ref to \subref{subsection}. + + +\subsubsection{Subsubsection\label{sub:Subsubsection}} + +Ref to \subref{Subsubsection}. + + +\paragraph{paragraph\label{par:paragraph}} + +\parref{paragraph} + + +\subparagraph{subparagraph\label{par:subparagraph}} + +\parref{subparagraph} + +\begin{figure} +\protect\caption{figure\label{fig:figure}} +\end{figure} + + +\figref{figure} + +\begin{table} +\protect\caption{table\label{tab:table}} +\end{table} + + +\tabref{table} + +\begin{algorithm} +\protect\caption{algorithm\label{alg:algorithm}} +\end{algorithm} + + +\algref{algorithm} + +\footnote{foot\label{fn:foot}% +} + +\fnref{foot} + +\marginpar{margin\label{margin}} + +\ref{margin} +\begin{enumerate} +\item item\label{enu:item} +\end{enumerate} +\enuref{item} + +\begin{equation} +A=B\label{eq:A=00003DB} +\end{equation} + + +\eqref{A=00003DB} +\begin{lem} +lemma\label{lem:lemma} + +\lemref{lemma}\end{lem} +\begin{thm} +theorem\label{thm:theorem} + +\thmref{theorem}\end{thm} +\begin{cor} +corollary\label{cor:corollary} + +\corref{corollary}\end{cor} +\begin{prop} +proposition\label{prop:proposition} + +\propref{proposition}\end{prop} +\begin{conjecture} +conjecture\label{conjecture} + +\ref{conjecture}\end{conjecture} +\begin{fact} +fact\label{fact} + +\ref{fact}\end{fact} +\begin{defn} +definition\label{definition} + +\ref{definition}\end{defn} +\begin{example} +example\label{example} + +\ref{example}\end{example} +\begin{problem} +problem\label{problem} + +\ref{problem}\end{problem} +\begin{xca} +exercise\label{exercise} + +\ref{exercise}\end{xca} +\begin{rem} +remark\label{remark} + +\ref{remark}\end{rem} +\begin{claim} +claim\label{claim} + +\ref{claim}\end{claim} +\begin{proof} +proof\label{proof} + +\ref{proof}\end{proof} + +\end{document}