mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +00:00
Disentangle amsmath and amssymb loading.
This is needed if you load a font package incompatible to amssymb manually (see bug #5058).
This commit is contained in:
parent
2e42350523
commit
b86c984bf4
@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2012-05-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
* Format incremented to 431
|
||||
Add \use_package amssymb
|
||||
|
||||
2012-04-16 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
* Format incremented to 430 (2773345)
|
||||
Support \lstlistoflistings in InsetTOC
|
||||
|
@ -31,8 +31,7 @@ from parser_tools import del_token, find_token, find_end_of, find_end_of_inset,
|
||||
|
||||
#from parser_tools import find_token, find_end_of, find_tokens, \
|
||||
#find_token_exact, find_end_of_inset, find_end_of_layout, \
|
||||
#find_token_backwards, is_in_inset, get_value, get_quoted_value, \
|
||||
#del_token, check_token
|
||||
#find_token_backwards, is_in_inset, del_token, check_token
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert
|
||||
|
||||
@ -730,6 +729,45 @@ def revert_listoflistings(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def convert_use_amssymb(document):
|
||||
"insert use_package amssymb"
|
||||
regexp = re.compile(r'(\\use_package\s+amsmath)')
|
||||
i = find_re(document.header, regexp, 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed LyX document: Can't find \\use_package amsmath.")
|
||||
return;
|
||||
value = get_value(document.header, "\\use_package" , i).split()[1]
|
||||
useamsmath = 0
|
||||
try:
|
||||
useamsmath = int(value)
|
||||
except:
|
||||
document.warning("Invalid \\use_package amsmath: " + value + ". Assuming auto.")
|
||||
useamsmath = 1
|
||||
j = find_token(document.preamble, "\\usepackage{amssymb}", 0)
|
||||
if j == -1:
|
||||
document.header.insert(i + 1, "\\use_package amssymb %d" % useamsmath)
|
||||
else:
|
||||
document.header.insert(i + 1, "\\use_package amssymb 2")
|
||||
del document.preamble[j]
|
||||
|
||||
|
||||
def revert_use_amssymb(document):
|
||||
"remove use_package amssymb"
|
||||
regexp1 = re.compile(r'(\\use_package\s+amsmath)')
|
||||
regexp2 = re.compile(r'(\\use_package\s+amssymb)')
|
||||
i = find_re(document.header, regexp1, 0)
|
||||
j = find_re(document.header, regexp2, 0)
|
||||
value1 = "1" # default is auto
|
||||
value2 = "1" # default is auto
|
||||
if i != -1:
|
||||
value1 = get_value(document.header, "\\use_package" , i).split()[1]
|
||||
if j != -1:
|
||||
value2 = get_value(document.header, "\\use_package" , j).split()[1]
|
||||
del document.header[j]
|
||||
if value1 != value2 and value2 == "2": # on
|
||||
add_to_preamble(document, ["\\usepackage{amssymb}"])
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -753,9 +791,11 @@ convert = [
|
||||
[428, [convert_cell_rotation]],
|
||||
[429, [convert_table_rotation]],
|
||||
[430, [convert_listoflistings]],
|
||||
[431, [convert_use_amssymb]],
|
||||
]
|
||||
|
||||
revert = [
|
||||
[430, [revert_use_amssymb]],
|
||||
[429, [revert_listoflistings]],
|
||||
[428, [revert_table_rotation]],
|
||||
[427, [revert_cell_rotation]],
|
||||
|
@ -447,6 +447,7 @@ vector<string> const & BufferParams::auto_packages()
|
||||
if (packages.empty()) {
|
||||
// adding a package here implies a file format change!
|
||||
packages.push_back("amsmath");
|
||||
packages.push_back("amssymb");
|
||||
packages.push_back("esint");
|
||||
packages.push_back("mathdots");
|
||||
packages.push_back("mathtools");
|
||||
|
@ -1066,7 +1066,7 @@ string const LaTeXFeatures::loadAMSPackages() const
|
||||
}
|
||||
|
||||
if (mustProvide("amssymb")
|
||||
|| params_.use_package("amsmath") == BufferParams::package_on)
|
||||
&& params_.use_package("amssymb") != BufferParams::package_off)
|
||||
tmp << "\\usepackage{amssymb}\n";
|
||||
|
||||
return tmp.str();
|
||||
|
@ -175,9 +175,13 @@ char const * backref_opts_gui[] =
|
||||
char const * packages_gui[][4] =
|
||||
{
|
||||
{"amsmath",
|
||||
N_("&Use AMS math package automatically"),
|
||||
N_("Use AMS &math package"),
|
||||
N_("The AMS LaTeX packages are only used if symbols from the AMS math toolbars are inserted into formulas")},
|
||||
N_("&Use amsmath package automatically"),
|
||||
N_("Use ams&math package"),
|
||||
N_("The LaTeX package amsmath is only used if AMS formula types or symbols from the AMS math toolbars are inserted into formulas")},
|
||||
{"amssymb",
|
||||
N_("&Use amssymb package automatically"),
|
||||
N_("Use amssymb package"),
|
||||
N_("The LaTeX package amssymb is only used if symbols from the AMS math toolbars are inserted into formulas")},
|
||||
{"esint",
|
||||
N_("Use esint package &automatically"),
|
||||
N_("Use &esint package"),
|
||||
|
@ -466,6 +466,7 @@ Preamble::Preamble() : one_language(true), title_layout_found(false)
|
||||
h_use_hyperref = "0";
|
||||
h_use_refstyle = "0";
|
||||
h_use_packages["amsmath"] = "1";
|
||||
h_use_packages["amssymb"] = "0";
|
||||
h_use_packages["esint"] = "1";
|
||||
h_use_packages["mhchem"] = "0";
|
||||
h_use_packages["mathdots"] = "0";
|
||||
@ -653,10 +654,8 @@ void Preamble::handle_package(Parser &p, string const & name,
|
||||
|| is_known(name, known_typewriter_fonts))
|
||||
;
|
||||
|
||||
else if (name == "amsmath" || name == "amssymb")
|
||||
h_use_packages["amsmath"] = "2";
|
||||
|
||||
else if (name == "esint" || name == "mhchem" || name == "mathdots" ||
|
||||
else if (name == "amsmath" || name == "amssymb" ||
|
||||
name == "esint" || name == "mhchem" || name == "mathdots" ||
|
||||
name == "mathtools" || name == "undertilde")
|
||||
h_use_packages[name] = "2";
|
||||
|
||||
@ -849,7 +848,6 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
|
||||
// amsbsy and amstext are already provided by amsmath
|
||||
registerAutomaticallyLoadedPackage("amsbsy");
|
||||
registerAutomaticallyLoadedPackage("amstext");
|
||||
registerAutomaticallyLoadedPackage("amssymb");
|
||||
}
|
||||
|
||||
// output the LyX file settings
|
||||
|
@ -30,8 +30,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 430 // gb: listoflistings
|
||||
#define LYX_FORMAT_TEX2LYX 430 // gb: listoflistings
|
||||
#define LYX_FORMAT_LYX 431 // gb: load switch for amssymb
|
||||
#define LYX_FORMAT_TEX2LYX 431 // gb: load switch for amssymb
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user