mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Avoid ugly macros in the preamble and protect underlined \cite commands
in a clever way. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29558 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
440df1c789
commit
128c2b31d8
@ -3,8 +3,7 @@ LyX file-format changes
|
||||
|
||||
2009-05-05 Pavel Sanda, Enrico Forestieri
|
||||
* Format incremented to 357: Change of the latex output for underline
|
||||
from \underbar to ulem's \uline. This point also corresponds to
|
||||
the introduction of \lyxuline etc. macros to avoid clash with \cite.
|
||||
from \underbar to ulem's \uline.
|
||||
|
||||
2009-05-05 Pavel Sanda <sanda@lyx.org>
|
||||
* Format incremented to 356: support for double and wave underline character
|
||||
|
24
src/Font.cpp
24
src/Font.cpp
@ -552,23 +552,27 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.underbar() == FONT_ON) {
|
||||
os << "\\lyxuline{";
|
||||
os << "\\uline{";
|
||||
count += 10;
|
||||
runparams.inulemcmd = true;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.strikeout() == FONT_ON) {
|
||||
os << "\\lyxsout{";
|
||||
os << "\\sout{";
|
||||
count += 9;
|
||||
runparams.inulemcmd = true;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.uuline() == FONT_ON) {
|
||||
os << "\\lyxuuline{";
|
||||
os << "\\uuline{";
|
||||
count += 11;
|
||||
runparams.inulemcmd = true;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.uwave() == FONT_ON) {
|
||||
os << "\\lyxuwave{";
|
||||
os << "\\uwave{";
|
||||
count += 10;
|
||||
runparams.inulemcmd = true;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
// \noun{} is a LyX special macro
|
||||
@ -638,21 +642,25 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
|
||||
if (f.underbar() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
runparams.inulemcmd = false;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.strikeout() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
runparams.inulemcmd = false;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.uuline() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
runparams.inulemcmd = false;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.uwave() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
runparams.inulemcmd = false;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.noun() == FONT_ON) {
|
||||
@ -821,29 +829,21 @@ void Font::validate(LaTeXFeatures & features) const
|
||||
if (bits_.underbar() == FONT_ON) {
|
||||
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()) {
|
||||
|
@ -164,23 +164,6 @@ 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"
|
||||
@ -759,21 +742,6 @@ 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';
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace lyx {
|
||||
|
||||
|
||||
OutputParams::OutputParams(Encoding const * enc)
|
||||
: flavor(LATEX), nice(false), moving_arg(false),
|
||||
: flavor(LATEX), nice(false), moving_arg(false), inulemcmd(false),
|
||||
local_font(0), encoding(enc), free_spacing(false), use_babel(false),
|
||||
use_indices(false), use_japanese(false), linelen(0), depth(0),
|
||||
exportdata(new ExportData),
|
||||
|
@ -75,6 +75,14 @@ public:
|
||||
*/
|
||||
bool intitle;
|
||||
|
||||
/** inulemcmd == true means that the environment in which the
|
||||
inset is typeset is part of a ulem command (\uline, \uuline,
|
||||
\uwave, or \sout). Insets that output latex commands relying
|
||||
on local assignments (such as \cite) should enclose such
|
||||
commands in \mbox{} in order to avoid breakage.
|
||||
*/
|
||||
mutable bool inulemcmd;
|
||||
|
||||
/** the font at the point where the inset is
|
||||
*/
|
||||
Font const * local_font;
|
||||
|
@ -535,13 +535,16 @@ void InsetCitation::tocString(odocstream & os) const
|
||||
// the \cite command is valid. Eg, the user has natbib enabled, inputs some
|
||||
// citations and then changes his mind, turning natbib support off. The output
|
||||
// should revert to \cite[]{}
|
||||
int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
||||
int InsetCitation::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
CiteEngine cite_engine = buffer().params().citeEngine();
|
||||
// FIXME UNICODE
|
||||
docstring const cite_str = from_utf8(
|
||||
asValidLatexCommand(getCmdName(), cite_engine));
|
||||
|
||||
if (runparams.inulemcmd)
|
||||
os << "\\mbox{";
|
||||
|
||||
os << "\\" << cite_str;
|
||||
|
||||
docstring const & before = getParam("before");
|
||||
@ -553,6 +556,9 @@ int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
||||
|
||||
os << '{' << cleanupWhitespace(getParam("key")) << '}';
|
||||
|
||||
if (runparams.inulemcmd)
|
||||
os << "}";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user