File format change.
def revert_negative_space(document):
- "Revert InsetSpace negmedspace and negthickspace into its TeX-code counterpart"
+ "Revert InsetSpace negmedspace and negthickspace into their TeX-code counterparts"
i = 0
j = 0
reverted = False
if reverted == True:
i = find_token(document.header, "\\use_amsmath 2", 0)
if i == -1:
- add_to_preamble(document, ["\\@ifundefined{negthickspace}{\\usepackage{amsmath}}"])
+ add_to_preamble(document, ["\\@ifundefined{negthickspace}{\\usepackage{amsmath}}{}"])
return
if i == -1:
return
if pretext:
add_to_preamble(document, pretext)
+
+def revert_ams_spaces(document):
+ "Revert InsetSpace medspace and thickspace into their TeX-code counterparts"
+ Found = False
+ insets = ["\\medspace{}", "\\thickspace{}"]
+ for inset in insets:
+ i = 0
+ j = 0
+ i = find_token(document.body, "\\begin_inset space " + inset, i)
+ if i == -1:
+ continue
+ end = find_end_of_inset(document.body, i)
+ subst = put_cmd_in_ert(inset)
+ document.body[i : end + 1] = subst
+ Found = True
+
+ if Found == True:
+ # load amsmath in the preamble if not already loaded
+ i = find_token(document.header, "\\use_package amsmath 2", 0)
+ if i == -1:
+ add_to_preamble(document, ["\\@ifundefined{thickspace}{\\usepackage{amsmath}}{}"])
+ return
##
# Conversion hub
[591, [convert_postpone_fragile]],
[592, []],
[593, [convert_counter_maintenance]],
- [594, []]
+ [594, []],
+ [595, []]
]
-revert = [[593, [revert_counter_inset]],
+revert = [[594, [revert_ams_spaces]],
+ [593, [revert_counter_inset]],
[592, [revert_counter_maintenance]],
[591, [revert_colrow_tracking]],
[590, [revert_postpone_fragile]],
Item "Protected Space|o" "inset-modify space ~"
Item "Visible Space|a" "inset-modify space \textvisiblespace{}"
Item "Thin Space|T" "inset-modify space \thinspace{}"
+ Item "Medium Space|M" "inset-modify space \medspace{}"
+ Item "Thick Space|i" "inset-modify space \thickspace{}"
Item "Negative Thin Space|N" "inset-modify space \negthinspace{}"
Item "Negative Medium Space|v" "inset-modify space \negmedspace{}"
Item "Negative Thick Space|h" "inset-modify space \negthickspace{}"
Item "Quad Space|Q" "inset-modify space \quad{}"
Item "Double Quad Space|u" "inset-modify space \qquad{}"
Item "Horizontal Fill|F" "inset-modify space \hfill{}"
- Item "Protected Horizontal Fill|i" "inset-modify space \hspace*{\fill}"
+ Item "Protected Horizontal Fill|z" "inset-modify space \hspace*{\fill}"
Item "Horizontal Fill (Dots)|D" "inset-modify space \dotfill{}"
Item "Horizontal Fill (Rule)|R" "inset-modify space \hrulefill{}"
Item "Horizontal Fill (Left Arrow)|L" "inset-modify space \leftarrowfill{}"
setupUi(this);
spacingCO->clear();
- if (math_mode_) {
- spacingCO->addItem(qt_("Interword Space"), "normal");
- spacingCO->addItem(qt_("Thin Space"), "thinspace");
- spacingCO->addItem(qt_("Medium Space"), "medspace");
- spacingCO->addItem(qt_("Thick Space"), "thickspace");
- spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
- spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
- spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
- spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
- spacingCO->addItem(qt_("Quad (1 em)"), "quad");
- spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
- spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
- spacingCO->addItem(qt_("Custom"), "custom");
- } else {
- spacingCO->addItem(qt_("Interword Space"), "normal");
- spacingCO->addItem(qt_("Thin Space"), "thinspace");
- spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
- spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
- spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
- spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
- spacingCO->addItem(qt_("Quad (1 em)"), "quad");
- spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
- spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
- spacingCO->addItem(qt_("Custom"), "custom");
+ spacingCO->addItem(qt_("Interword Space"), "normal");
+ spacingCO->addItem(qt_("Thin Space"), "thinspace");
+ spacingCO->addItem(qt_("Medium Space"), "medspace");
+ spacingCO->addItem(qt_("Thick Space"), "thickspace");
+ spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
+ spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
+ spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
+ spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
+ spacingCO->addItem(qt_("Quad (1 em)"), "quad");
+ spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
+ spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
+ if (!math_mode_)
spacingCO->addItem(qt_("Visible Space"), "visible");
- }
+ spacingCO->addItem(qt_("Custom"), "custom");
connect(spacingCO, SIGNAL(highlighted(QString)),
this, SLOT(changedSlot()));
kind = InsetSpaceParams::VISIBLE;
else if (command == "\\thinspace{}")
kind = InsetSpaceParams::THIN;
- else if (math && command == "\\medspace{}")
+ else if (command == "\\medspace{}")
kind = InsetSpaceParams::MEDIUM;
- else if (math && command == "\\thickspace{}")
+ else if (command == "\\thickspace{}")
kind = InsetSpaceParams::THICK;
else if (command == "\\quad{}")
kind = InsetSpaceParams::QUAD;
os << (runparams.free_spacing ? " " : "\\,");
break;
case InsetSpaceParams::MEDIUM:
- os << (runparams.free_spacing ? " " : "\\:");
+ if (params_.math)
+ os << (runparams.free_spacing ? " " : "\\:");
+ else
+ os << (runparams.free_spacing ? " " : "\\medspace{}");
break;
case InsetSpaceParams::THICK:
- os << (runparams.free_spacing ? " " : "\\;");
+ if (params_.math)
+ os << (runparams.free_spacing ? " " : "\\;");
+ else
+ os << (runparams.free_spacing ? " " : "\\thickspace{}");
break;
case InsetSpaceParams::QUAD:
os << (runparams.free_spacing ? " " : "\\quad{}");
void InsetSpace::validate(LaTeXFeatures & features) const
{
- if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
- params_.kind == InsetSpaceParams::NEGTHICK)
+ if ((params_.kind == InsetSpaceParams::NEGMEDIUM
+ || params_.kind == InsetSpaceParams::NEGTHICK)
+ || (!params_.math
+ && (params_.kind == InsetSpaceParams::MEDIUM
+ || params_.kind == InsetSpaceParams::THICK)))
features.require("amsmath");
}
/// spaces known by InsetSpace
char const * const known_spaces[] = { " ", "space", ",",
"thinspace", "quad", "qquad", "enspace", "enskip",
-"negthinspace", "negmedspace", "negthickspace", "textvisiblespace",
-"hfill", "dotfill", "hrulefill", "leftarrowfill", "rightarrowfill",
-"upbracefill", "downbracefill", 0};
+"medspace", "thickspace", "negthinspace", "negmedspace", "negthickspace",
+"textvisiblespace", "hfill", "dotfill", "hrulefill", "leftarrowfill",
+"rightarrowfill", "upbracefill", "downbracefill", 0};
/// the same as known_spaces with .lyx names
char const * const known_coded_spaces[] = { "space{}", "space{}",
"thinspace{}", "thinspace{}", "quad{}", "qquad{}", "enspace{}", "enskip{}",
-"negthinspace{}", "negmedspace{}", "negthickspace{}", "textvisiblespace{}",
-"hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}", "rightarrowfill{}",
-"upbracefill{}", "downbracefill{}", 0};
+"medspace{}", "thickspace{}", "negthinspace{}", "negmedspace{}", "negthickspace{}",
+"textvisiblespace{}", "hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}",
+"rightarrowfill{}", "upbracefill{}", "downbracefill{}", 0};
/// known TIPA combining diacritical marks
char const * const known_tipa_marks[] = {"textsubwedge", "textsubumlaut",
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 594 // rikiheck: counter insets
-#define LYX_FORMAT_TEX2LYX 594
+#define LYX_FORMAT_LYX 595 // spitz: medspace and thickspace
+#define LYX_FORMAT_TEX2LYX 595
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER