commit dbe0096c126f92cbd67704af8a7aba288741511a
Author: Juergen Spitzmueller <[email protected]>
Date: Sun May 24 13:50:21 2015 +0200
Rename ref prefix "sub:" to "subsec:"
This solves a macro conflict between subfloat's \subref and our own
\subref definition (bug #7550)
File format change.
diff --git a/development/FORMAT b/development/FORMAT
index fb2088b..770ceaa 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in
lyx2lyx.
-----------------------
+2015-05-24 Jürgen Spitzmüller <[email protected]>
+ * Format incremented to 495: Rename sub: refprefix to subsec: in order
+ to prevent clash of \\subref command with subfloat package.
+
2015-05-24 Uwe Stöhr <[email protected]>
* Format incremented to 494: support more layouts in jss.layout
No new parameters.
diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index 0127d9f..8d255bd 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -12,6 +12,12 @@
the GUI (though some menu entries use it) as it is automatically inserted
when needed. See Section 3.4.6 of the User Guide for details.
+* The prefix for subsections in labels and references has been changed from
+ "sub:" to "subsec:" in order to avoid a clash with subfloats (conflicting
+ \subref command, see bug #7550). Files are automatically converted to the
new scheme.
+ Please assure that you adapt external refstyle or prettyref definitions and
+ your own layout files.
+
!!!The following pref variables were added in 2.2:
* \save_origin:
diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index a56dbd9..b8390d3 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -309,7 +309,7 @@ Style Subsection
LabelType Static
LabelCounter subsection
LabelString "Subsection \arabic{section}.\arabic{subsection}"
- RefPrefix sub
+ RefPrefix subsec
Argument 1
LabelString "Mode"
MenuString "Mode Specification|S"
diff --git a/lib/layouts/stdrefprefix.inc b/lib/layouts/stdrefprefix.inc
index 7412d95..3efe819 100644
--- a/lib/layouts/stdrefprefix.inc
+++ b/lib/layouts/stdrefprefix.inc
@@ -22,11 +22,11 @@ IfStyle Section
End
IfStyle Subsection
- RefPrefix sub
+ RefPrefix subsec
End
IfStyle Subsubsection
- RefPrefix sub
+ RefPrefix subsec
End
IfStyle Paragraph
diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout
index da6c7b1..3a191a4 100644
--- a/lib/layouts/tufte-book.layout
+++ b/lib/layouts/tufte-book.layout
@@ -122,7 +122,7 @@ Style Subsection
TopSep 0.9
BottomSep 0.5
ParSep 0.5
- RefPrefix sub
+ RefPrefix subsec
Font
Series Bold
Size Large
diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index 15ad32c..73818fa 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" ,
4)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
- ("2_2", list(range(475,495)), minor_versions("2.2" , 0))
+ ("2_2", list(range(475,496)), minor_versions("2.2" , 0))
]
####################################################################
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index 18f4838..c18d905 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -1424,6 +1424,98 @@ def revert_jss(document):
k = k + 1
+def convert_subref(document):
+ " converts sub: ref prefixes to subref: "
+
+ # 1) label insets
+ rx = re.compile(r'^name \"sub:(.+)$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset label", i)
+ if i == -1:
+ break
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of Label
inset at line " + str(i))
+ i += 1
+ continue
+
+ for p in range(i, j):
+ m = rx.match(document.body[p])
+ if m:
+ label = m.group(1)
+ document.body[p] = "name \"subsec:" + label
+ i += 1
+
+ # 2) xref insets
+ rx = re.compile(r'^reference \"sub:(.+)$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of Ref
inset at line " + str(i))
+ i += 1
+ continue
+
+ for p in range(i, j):
+ m = rx.match(document.body[p])
+ if m:
+ label = m.group(1)
+ document.body[p] = "reference \"subsec:" + label
+ break
+ i += 1
+
+
+
+def revert_subref(document):
+ " reverts subref: ref prefixes to sub: "
+
+ # 1) label insets
+ rx = re.compile(r'^name \"subsec:(.+)$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset label", i)
+ if i == -1:
+ break
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of Label
inset at line " + str(i))
+ i += 1
+ continue
+
+ for p in range(i, j):
+ m = rx.match(document.body[p])
+ if m:
+ label = m.group(1)
+ document.body[p] = "name \"sub:" + label
+ break
+ i += 1
+
+ # 2) xref insets
+ rx = re.compile(r'^reference \"subsec:(.+)$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of Ref
inset at line " + str(i))
+ i += 1
+ continue
+
+ for p in range(i, j):
+ m = rx.match(document.body[p])
+ if m:
+ label = m.group(1)
+ document.body[p] = "reference \"sub:" + label
+ break
+ i += 1
+
+
##
# Conversion hub
#
@@ -1452,10 +1544,12 @@ convert = [
[491, []],
[492, [convert_colorbox]],
[493, []],
- [494, []]
+ [494, []],
+ [495, [convert_subref]]
]
revert = [
+ [494, [revert_subref]],
[493, [revert_jss]],
[492, [revert_mathmulticol]],
[491, [revert_colorbox]],
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 84c492b..5a05ef1 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -249,8 +249,8 @@ static docstring const ogonek_def = from_ascii(
"\\newcommand{\\ogonek}[1]{\\mathpalette\\doogonek{#1}}\n");
static docstring const lyxref_def = from_ascii(
- "\\RS@ifundefined{subref}\n"
- " {\\def\\RSsubtxt{section~}\\newref{sub}{name =
\\RSsubtxt}}\n"
+ "\\RS@ifundefined{subsecref}\n"
+ " {\\newref{subsec}{name = \\RSsectxt}}\n"
" {}\n"
"\\RS@ifundefined{thmref}\n"
" {\\def\\RSthmtxt{theorem~}\\newref{thm}{name =
\\RSthmtxt}}\n"
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index ed2a3f7..d510c00 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -137,11 +137,11 @@ char const * const known_coded_ref_commands[] = { "ref",
"pageref", "vref",
char const * const known_refstyle_commands[] = { "algref", "chapref", "corref",
"eqref", "enuref", "figref", "fnref", "lemref", "parref", "partref",
"propref",
- "secref", "subref", "tabref", "thmref", 0 };
+ "secref", "subsecref", "tabref", "thmref", 0 };
char const * const known_refstyle_prefixes[] = { "alg", "chap", "cor",
"eq", "enu", "fig", "fn", "lem", "par", "part", "prop",
- "sec", "sub", "tab", "thm", 0 };
+ "sec", "subsec", "tab", "thm", 0 };
/**
diff --git a/src/version.h b/src/version.h
index 9746f1b..79ea6cc 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 494 // uwestoehr jss layout changes
-#define LYX_FORMAT_TEX2LYX 494
+#define LYX_FORMAT_LYX 495 // spitz: subsection ref prefix change
+#define LYX_FORMAT_TEX2LYX 495
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER