]> git.lyx.org Git - features.git/commitdiff
Solve problem with underlining citations.
authorEnrico Forestieri <forenr@lyx.org>
Wed, 6 May 2009 10:20:40 +0000 (10:20 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 6 May 2009 10:20:40 +0000 (10:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29550 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py
src/Font.cpp
src/LaTeXFeatures.cpp

index eb150330ba724c4d8dec2f6a9f1b533800b4bd32..153bcac7a8b601da23c3a2c8bffab032f241d3ec 100644 (file)
@@ -435,6 +435,9 @@ def revert_backgroundcolor(document):
           return
       colorcode = get_value(document.header, '\\backgroundcolor', 0)
       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
       # convert the string to an int
       red = string.atoi(colorcode[1:3],16)
@@ -615,7 +618,7 @@ def revert_strikeout(document):
 
 
 def revert_uulinewave(document):
-    " Reverts \\uuline and \\uwave character style "
+    " Reverts \\uline, \\uuline, and \\uwave character styles "
     while True:
         i = find_token(document.body, '\\uuline', 0)
         if i == -1:
@@ -624,8 +627,19 @@ def revert_uulinewave(document):
     while True:
         i = find_token(document.body, '\\uwave', 0)
         if i == -1:
-            return
+            break
         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')
 
 
 ##
index 0290f91961cc16fe4e58628eeda9de978e7f4508..0a9e302b60ea0f08108ab0180548acdbd5d5d063 100644 (file)
@@ -552,23 +552,23 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                env = true; //We have opened a new environment
        }
        if (f.underbar() == FONT_ON) {
-               os << "\\uline{";
+               os << "\\lyxuline{";
                count += 10;
                env = true; //We have opened a new environment
        }
        if (f.strikeout() == FONT_ON) {
-               os << "\\sout{";
-               count += 6;
+               os << "\\lyxsout{";
+               count += 9;
                env = true; //We have opened a new environment
        }
        if (f.uuline() == FONT_ON) {
-               os << "\\uuline{";
-               count += 8;
+               os << "\\lyxuuline{";
+               count += 11;
                env = true; //We have opened a new environment
        }
        if (f.uwave() == FONT_ON) {
-               os << "\\uwave{";
-               count += 7;
+               os << "\\lyxuwave{";
+               count += 10;
                env = true; //We have opened a new environment
        }
        // \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)));
        }
        if (bits_.underbar() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.underline: " << bits_.strikeout());
+               LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
                features.require("ulem");
+               features.require("boxcite");
+               features.require("lyxuline");
                LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0)));
        }
        if (bits_.strikeout() == FONT_ON) {
                LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
                features.require("ulem");
+               features.require("boxcite");
+               features.require("lyxsout");
                LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0)));
        }
        if (bits_.uuline() == FONT_ON) {
                LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
                features.require("ulem");
+               features.require("boxcite");
+               features.require("lyxuuline");
                LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0)));
        }
        if (bits_.uwave() == FONT_ON) {
                LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
                features.require("ulem");
+               features.require("boxcite");
+               features.require("lyxuwave");
                LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0)));
        }
        switch (bits_.color()) {
index efc3fc6a3be58fd75c0941e40c39064a310a3e51..6842b3e0cf8705085c2a8dd0b70251f51c973931 100644 (file)
@@ -164,6 +164,23 @@ static string const lyxdot_def =
        "%% A simple dot to overcome graphicx limitations\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 =
        "%% Change tracking with dvipost\n"
        "\\dvipostlayout\n"
@@ -742,6 +759,21 @@ string const LaTeXFeatures::getMacros() const
        if (mustProvide("lyxline"))
                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"))
                macros << noun_def << '\n';