mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 14:32:04 +00:00
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
This commit is contained in:
parent
fb64fe613f
commit
a99241266b
@ -1370,6 +1370,66 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
p.setCatcode('@', catOther);
|
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"
|
else if (t.cs() == "newcommand" || t.cs() == "newcommandx"
|
||||||
|| t.cs() == "renewcommand" || t.cs() == "renewcommandx"
|
|| t.cs() == "renewcommand" || t.cs() == "renewcommandx"
|
||||||
|| t.cs() == "providecommand" || t.cs() == "providecommandx"
|
|| t.cs() == "providecommand" || t.cs() == "providecommandx"
|
||||||
@ -1414,7 +1474,6 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
p.skip_spaces();
|
p.skip_spaces();
|
||||||
in_lyx_preamble = true;
|
in_lyx_preamble = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == "\\bfdefault")
|
if (name == "\\bfdefault")
|
||||||
// LyX re-adds this if a kurier font is used
|
// LyX re-adds this if a kurier font is used
|
||||||
if (is_known(h_font_sans, known_kurier_fonts) && body == "b") {
|
if (is_known(h_font_sans, known_kurier_fonts) && body == "b") {
|
||||||
|
@ -1,44 +1,20 @@
|
|||||||
#LyX file created by tex2lyx 2.1.0dev
|
#LyX file created by tex2lyx 2.1.0dev
|
||||||
\lyxformat 461
|
\lyxformat 462
|
||||||
\begin_document
|
\begin_document
|
||||||
\begin_header
|
\begin_header
|
||||||
\textclass book
|
\textclass book
|
||||||
\begin_preamble
|
\begin_preamble
|
||||||
\usepackage{refstyle}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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}
|
\floatstyle{ruled}
|
||||||
\newfloat{algorithm}{tbp}{loa}[chapter]
|
\newfloat{algorithm}{tbp}{loa}[chapter]
|
||||||
\providecommand{\algorithmname}{Algorithm}
|
\providecommand{\algorithmname}{Algorithm}
|
||||||
\floatname{algorithm}{\protect\algorithmname}
|
\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.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
|
Loading…
Reference in New Issue
Block a user