Solve problem with underlining citations.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29550 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-05-06 10:20:40 +00:00
parent 1990c00e5c
commit cd62043a1b
3 changed files with 64 additions and 10 deletions

View File

@ -435,6 +435,9 @@ def revert_backgroundcolor(document):
return return
colorcode = get_value(document.header, '\\backgroundcolor', 0) colorcode = get_value(document.header, '\\backgroundcolor', 0)
del document.header[i] del document.header[i]
# don't clutter the preamble if backgroundcolor is not set
if colorcode == "#ffffff":
continue
# the color code is in the form #rrggbb where every character denotes a hex number # the color code is in the form #rrggbb where every character denotes a hex number
# convert the string to an int # convert the string to an int
red = string.atoi(colorcode[1:3],16) red = string.atoi(colorcode[1:3],16)
@ -615,7 +618,7 @@ def revert_strikeout(document):
def revert_uulinewave(document): def revert_uulinewave(document):
" Reverts \\uuline and \\uwave character style " " Reverts \\uline, \\uuline, and \\uwave character styles "
while True: while True:
i = find_token(document.body, '\\uuline', 0) i = find_token(document.body, '\\uuline', 0)
if i == -1: if i == -1:
@ -624,8 +627,19 @@ def revert_uulinewave(document):
while True: while True:
i = find_token(document.body, '\\uwave', 0) i = find_token(document.body, '\\uwave', 0)
if i == -1: if i == -1:
return break
del document.body[i] del document.body[i]
i = find_token(document.body, '\\bar under', 0)
if i == -1:
return
insert_to_preamble(0, document,
'% Commands inserted by lyx2lyx for proper underlining\n'
+ '\\PassOptionsToPackage{normalem}{ulem}\n'
+ '\\usepackage{ulem}\n'
+ '\\let\\cite@rig\\cite\n'
+ '\\newcommand{\\b@xcite}[2][\\%]{\\def\\def@pt{\\%}\\def\\pas@pt{#1}\n'
+ ' \\mbox{\\ifx\\def@pt\\pas@pt\\cite@rig{#2}\\else\\cite@rig[#1]{#2}\\fi}}\n'
+ '\\renewcommand{\\underbar}[1]{{\\let\\cite\\b@xcite\\uline{#1}}}\n')
## ##

View File

@ -552,23 +552,23 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
env = true; //We have opened a new environment env = true; //We have opened a new environment
} }
if (f.underbar() == FONT_ON) { if (f.underbar() == FONT_ON) {
os << "\\uline{"; os << "\\lyxuline{";
count += 10; count += 10;
env = true; //We have opened a new environment env = true; //We have opened a new environment
} }
if (f.strikeout() == FONT_ON) { if (f.strikeout() == FONT_ON) {
os << "\\sout{"; os << "\\lyxsout{";
count += 6; count += 9;
env = true; //We have opened a new environment env = true; //We have opened a new environment
} }
if (f.uuline() == FONT_ON) { if (f.uuline() == FONT_ON) {
os << "\\uuline{"; os << "\\lyxuuline{";
count += 8; count += 11;
env = true; //We have opened a new environment env = true; //We have opened a new environment
} }
if (f.uwave() == FONT_ON) { if (f.uwave() == FONT_ON) {
os << "\\uwave{"; os << "\\lyxuwave{";
count += 7; count += 10;
env = true; //We have opened a new environment env = true; //We have opened a new environment
} }
// \noun{} is a LyX special macro // \noun{} is a LyX special macro
@ -819,23 +819,31 @@ void Font::validate(LaTeXFeatures & features) const
LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0))); LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0)));
} }
if (bits_.underbar() == FONT_ON) { if (bits_.underbar() == FONT_ON) {
LYXERR(Debug::LATEX, "font.underline: " << bits_.strikeout()); LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
features.require("ulem"); features.require("ulem");
features.require("boxcite");
features.require("lyxuline");
LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0))); LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0)));
} }
if (bits_.strikeout() == FONT_ON) { if (bits_.strikeout() == FONT_ON) {
LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout()); LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
features.require("ulem"); features.require("ulem");
features.require("boxcite");
features.require("lyxsout");
LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0))); LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0)));
} }
if (bits_.uuline() == FONT_ON) { if (bits_.uuline() == FONT_ON) {
LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline()); LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
features.require("ulem"); features.require("ulem");
features.require("boxcite");
features.require("lyxuuline");
LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0))); LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0)));
} }
if (bits_.uwave() == FONT_ON) { if (bits_.uwave() == FONT_ON) {
LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave()); LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
features.require("ulem"); features.require("ulem");
features.require("boxcite");
features.require("lyxuwave");
LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0))); LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0)));
} }
switch (bits_.color()) { switch (bits_.color()) {

View File

@ -164,6 +164,23 @@ static string const lyxdot_def =
"%% A simple dot to overcome graphicx limitations\n" "%% A simple dot to overcome graphicx limitations\n"
"\\newcommand{\\lyxdot}{.}\n"; "\\newcommand{\\lyxdot}{.}\n";
static string const boxcite_def =
"\\let\\cite@rig\\cite\n"
"\\newcommand{\\b@xcite}[2][\\%]{\\def\\def@pt{\\%}\\def\\pas@pt{#1}\n"
" \\mbox{\\ifx\\def@pt\\pas@pt\\cite@rig{#2}\\else\\cite@rig[#1]{#2}\\fi}}\n";
static string const lyxuline_def =
"\\newcommand{\\lyxuline}[1]{{\\let\\cite\\b@xcite\\uline{#1}}}\n";
static string const lyxuuline_def =
"\\newcommand{\\lyxuuline}[1]{{\\let\\cite\\b@xcite\\uuline{#1}}}\n";
static string const lyxuwave_def =
"\\newcommand{\\lyxuwave}[1]{{\\let\\cite\\b@xcite\\uwave{#1}}}\n";
static string const lyxsout_def =
"\\newcommand{\\lyxsout}[1]{{\\let\\cite\\b@xcite\\sout{#1}}}\n";
static string const changetracking_dvipost_def = static string const changetracking_dvipost_def =
"%% Change tracking with dvipost\n" "%% Change tracking with dvipost\n"
"\\dvipostlayout\n" "\\dvipostlayout\n"
@ -742,6 +759,21 @@ string const LaTeXFeatures::getMacros() const
if (mustProvide("lyxline")) if (mustProvide("lyxline"))
macros << lyxline_def << '\n'; macros << lyxline_def << '\n';
if (mustProvide("boxcite"))
macros << boxcite_def << '\n';
if (mustProvide("lyxuline"))
macros << lyxuline_def << '\n';
if (mustProvide("lyxuuline"))
macros << lyxuuline_def << '\n';
if (mustProvide("lyxuwave"))
macros << lyxuwave_def << '\n';
if (mustProvide("lyxsout"))
macros << lyxsout_def << '\n';
if (mustProvide("noun")) if (mustProvide("noun"))
macros << noun_def << '\n'; macros << noun_def << '\n';