]> git.lyx.org Git - features.git/commitdiff
Fix bug #8552
authorGeorg Baum <baum@lyx.org>
Fri, 22 Feb 2013 21:21:56 +0000 (22:21 +0100)
committerGeorg Baum <baum@lyx.org>
Fri, 22 Feb 2013 21:21:56 +0000 (22:21 +0100)
tex2lyx skips LyX preamble code only if it thinks that the file was created
by LyX (i.e. special comments are found). I don't like that, but this is
how it works and therefore the special comment neds to be added if the
theorem commands are to be skipped. This header makes also the temporary
setting of in_lyx_preamble obsolete, which caused skipping of user preamble
commands, which were not re-added by LyX.

src/tex2lyx/Preamble.cpp
src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
src/tex2lyx/test/test-refstyle-theorems.tex

index 72800eca9579739082531a6ab3870cbfd5f06a40..b6155da9a8a0da40741c05badf630399120f5ae2 100644 (file)
@@ -1410,16 +1410,11 @@ void Preamble::parse(Parser & p, string const & forceclass,
                        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();
-                               in_lyx_preamble = true;
-                       }
                        // only non-lyxspecific stuff
-                       if (!in_lyx_preamble) {
+                       if (in_lyx_preamble &&
+                           (name == "subref" || name == "thmref" || name == "lemref"))
+                               p.skip_spaces();
+                       else {
                                ostringstream ss;
                                ss << '\\' << t.cs();
                                ss << '{' << name << '}'
@@ -1427,15 +1422,13 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                   << '{' << 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}}"
+                       // only non-lyxspecific stuff
+                       if (in_lyx_preamble &&
+                           (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}}"
@@ -1449,19 +1442,14 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                || 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}}") {
+                               || name == "\\providecommand\\propref[1]{\\ref{prop:#1}}"))
                                p.skip_spaces();
-                               in_lyx_preamble = true;
-                       }
-                       // only non-lyxspecific stuff
-                       if (!in_lyx_preamble) {
+                       else {
                                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"
index 3d58cd745523037a54dda9ee52633911d8770010..5f2554cbe099adb4e5701ac7b3dfaf10dcabbcf5 100644 (file)
@@ -8,6 +8,7 @@
 % Load refstyle before prettyref so that prettyref wins.
 % The real refstyle tests are in test-refstyle-theorems.tex.
 \usepackage{refstyle}
+\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}}
 
 
 \def\mycommand{\textquestiondown}
index e8cb4499d7bb6301e100ec0da127314b45400dd4..01d1b1b5dcf5447796b36fdcddae8d5a6b58bef1 100644 (file)
@@ -4,60 +4,7 @@
 \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
index 70ad4c65013f6380fb37641493a4ae9c2543fc6a..e0e2944e19e2d967dcf3b15052cbf0c743e28a51 100644 (file)
@@ -1,3 +1,5 @@
+%% LyX trick_preamble_code_into_believing_that_this_was_created_by_lyx created this file.  For more info, see http://www.lyx.org/.
+%% Do not edit unless you really know what you are doing.
 \documentclass[english]{book}
 \usepackage[T1]{fontenc}
 \usepackage[latin9]{inputenc}