mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
parent
793dd3b9c0
commit
49c887761a
@ -32,6 +32,7 @@ TEST_FILES = \
|
||||
test/test-insets.tex \
|
||||
test/test.ltx \
|
||||
test/test-modules.tex \
|
||||
test/test-refstyle-references.tex \
|
||||
test/test-structure.tex \
|
||||
test/XeTeX-polyglossia.tex \
|
||||
test/xfigtest.fig \
|
||||
|
@ -698,6 +698,9 @@ void Preamble::handle_package(Parser &p, string const & name,
|
||||
if (name == "eco")
|
||||
h_font_osf = "true";
|
||||
|
||||
if (name == "refstyle")
|
||||
h_use_refstyle = "1";
|
||||
|
||||
// after the detection and handling of special cases, we can remove the
|
||||
// fonts, otherwise they would appear in the preamble, see bug #7856
|
||||
if (is_known(name, known_roman_fonts) || is_known(name, known_sans_fonts)
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
///
|
||||
std::string notefontcolor() const { return h_notefontcolor; }
|
||||
///
|
||||
std::string refstyle() const { return h_use_refstyle; }
|
||||
///
|
||||
bool fontCJKSet() const { return h_font_cjk_set; }
|
||||
///
|
||||
std::string fontCJK() const { return h_font_cjk; }
|
||||
|
210
src/tex2lyx/test/test-refstyle-references.tex
Normal file
210
src/tex2lyx/test/test-refstyle-references.tex
Normal file
@ -0,0 +1,210 @@
|
||||
\documentclass[english]{book}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[latin9]{inputenc}
|
||||
\usepackage{refstyle}
|
||||
\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\Staref[1]{\ref{Sta:#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}}}
|
||||
\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{\label{Sta:figure}figure}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\Staref{figure}
|
||||
|
||||
\begin{table}
|
||||
\protect\caption{\label{Sta:table}table}
|
||||
\end{table}
|
||||
|
||||
|
||||
\Staref{table}
|
||||
|
||||
\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}
|
@ -117,6 +117,15 @@ char const * const known_ref_commands[] = { "ref", "pageref", "vref",
|
||||
char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref",
|
||||
"vpageref", "formatted", "eqref", 0 };
|
||||
|
||||
char const * const known_refstyle_commands[] = { "chapref", "corref", "eqref",
|
||||
"enuref", "fnref", "lemref", "parref", "partref", "propref", "secref", "Staref",
|
||||
"subref", "thmref", 0 };
|
||||
|
||||
char const * const known_refstyle_prefixes[] = { "chap", "cor", "eq",
|
||||
"enu", "fn", "lem", "par", "part", "prop", "sec", "Sta",
|
||||
"sub", "thm", 0 };
|
||||
|
||||
|
||||
/**
|
||||
* supported CJK encodings
|
||||
* JIS does not work with LyX's encoding conversion
|
||||
@ -3337,6 +3346,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
}
|
||||
|
||||
else if ((where = is_known(t.cs(), known_ref_commands))) {
|
||||
// \eqref can also occur if refstyle is used
|
||||
if (t.cs() == "eqref" && preamble.refstyle() == "1") {
|
||||
context.check_layout(os);
|
||||
begin_command_inset(os, "ref", "formatted");
|
||||
os << "reference \"eq:"
|
||||
<< convert_command_inset_arg(p.verbatim_item())
|
||||
<< "\"\n";
|
||||
end_inset(os);
|
||||
preamble.registerAutomaticallyLoadedPackage("refstyle");
|
||||
} else {
|
||||
string const opt = p.getOpt();
|
||||
if (opt.empty()) {
|
||||
context.check_layout(os);
|
||||
@ -3348,13 +3367,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
end_inset(os);
|
||||
if (t.cs() == "vref" || t.cs() == "vpageref")
|
||||
preamble.registerAutomaticallyLoadedPackage("varioref");
|
||||
|
||||
} else {
|
||||
// LyX does not support optional arguments of ref commands
|
||||
// LyX does not yet support optional arguments of ref commands
|
||||
handle_ert(os, t.asInput() + '[' + opt + "]{" +
|
||||
p.verbatim_item() + "}", context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ((where = is_known(t.cs(), known_refstyle_commands))) {
|
||||
context.check_layout(os);
|
||||
// \eqref can also occur if refstyle is not used
|
||||
// this case is already handled in the previous else if
|
||||
begin_command_inset(os, "ref", "formatted");
|
||||
os << "reference \"";
|
||||
os << known_refstyle_prefixes[where - known_refstyle_commands]
|
||||
<< ":";
|
||||
os << convert_command_inset_arg(p.verbatim_item())
|
||||
<< "\"\n";
|
||||
end_inset(os);
|
||||
preamble.registerAutomaticallyLoadedPackage("refstyle");
|
||||
}
|
||||
|
||||
else if (use_natbib &&
|
||||
is_known(t.cs(), known_natbib_commands) &&
|
||||
|
Loading…
Reference in New Issue
Block a user