mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 23:07:43 +00:00
tex2lyx:
- support for \makebox - fix import of boxes without an inner box (the on-screen display was broken because of wrong default width setting) - fix parsing of \framebox{content}, which LyX does not support yet - we have to use ERT git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40150 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d7320ad89b
commit
0fb02b561c
@ -57,7 +57,6 @@ Format LaTeX feature LyX feature
|
|||||||
390 forward/reverse search \forward_search, \forward_macro
|
390 forward/reverse search \forward_search, \forward_macro
|
||||||
391 decimal alignment in tables InsetTabular
|
391 decimal alignment in tables InsetTabular
|
||||||
392 new beamer format InsetLayout
|
392 new beamer format InsetLayout
|
||||||
394 \makebox InsetBox use_makebox
|
|
||||||
396 nameref.sty InsetRef
|
396 nameref.sty InsetRef
|
||||||
399 automatic mathdots loading \use_mathdots
|
399 automatic mathdots loading \use_mathdots
|
||||||
401 feyn.sty InsetMathDiagram
|
401 feyn.sty InsetMathDiagram
|
||||||
|
@ -741,16 +741,29 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
string height_unit = "in";
|
string height_unit = "in";
|
||||||
string height_special = "totalheight";
|
string height_special = "totalheight";
|
||||||
string latex_height;
|
string latex_height;
|
||||||
|
string width_value;
|
||||||
|
string width_unit;
|
||||||
|
string latex_width;
|
||||||
|
string width_special = "none";
|
||||||
if (!inner_type.empty() && p.hasOpt()) {
|
if (!inner_type.empty() && p.hasOpt()) {
|
||||||
|
if (inner_type != "makebox")
|
||||||
position = p.getArg('[', ']');
|
position = p.getArg('[', ']');
|
||||||
|
else {
|
||||||
|
latex_width = p.getArg('[', ']');
|
||||||
|
translate_box_len(latex_width, width_value, width_unit, width_special);
|
||||||
|
position = "t";
|
||||||
|
}
|
||||||
if (position != "t" && position != "c" && position != "b") {
|
if (position != "t" && position != "c" && position != "b") {
|
||||||
cerr << "invalid position " << position << " for "
|
cerr << "invalid position " << position << " for "
|
||||||
<< inner_type << endl;
|
<< inner_type << endl;
|
||||||
position = "c";
|
position = "c";
|
||||||
}
|
}
|
||||||
if (p.hasOpt()) {
|
if (p.hasOpt()) {
|
||||||
|
if (inner_type != "makebox") {
|
||||||
latex_height = p.getArg('[', ']');
|
latex_height = p.getArg('[', ']');
|
||||||
translate_box_len(latex_height, height_value, height_unit, height_special);
|
translate_box_len(latex_height, height_value, height_unit, height_special);
|
||||||
|
} else
|
||||||
|
hor_pos = p.getArg('[', ']');
|
||||||
|
|
||||||
if (p.hasOpt()) {
|
if (p.hasOpt()) {
|
||||||
inner_pos = p.getArg('[', ']');
|
inner_pos = p.getArg('[', ']');
|
||||||
@ -764,12 +777,9 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string width_value;
|
|
||||||
string width_unit;
|
|
||||||
string latex_width;
|
|
||||||
if (inner_type.empty()) {
|
if (inner_type.empty()) {
|
||||||
if (special.empty())
|
if (special.empty() && outer_type != "framebox")
|
||||||
latex_width = "\\columnwidth";
|
latex_width = "1\\columnwidth";
|
||||||
else {
|
else {
|
||||||
Parser p2(special);
|
Parser p2(special);
|
||||||
latex_width = p2.getArg('[', ']');
|
latex_width = p2.getArg('[', ']');
|
||||||
@ -784,9 +794,16 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else if (inner_type != "makebox")
|
||||||
latex_width = p.verbatim_item();
|
latex_width = p.verbatim_item();
|
||||||
|
// if e.g. only \ovalbox{content} was used, set the width to 1\columnwidth
|
||||||
|
// as this is LyX's standard for such cases (except for makebox)
|
||||||
|
if (latex_width.empty() && inner_type != "makebox"
|
||||||
|
&& outer_type != "framebox")
|
||||||
|
latex_width = "1\\columnwidth";
|
||||||
|
|
||||||
translate_len(latex_width, width_value, width_unit);
|
translate_len(latex_width, width_value, width_unit);
|
||||||
|
|
||||||
bool shadedparbox = false;
|
bool shadedparbox = false;
|
||||||
if (inner_type == "shaded") {
|
if (inner_type == "shaded") {
|
||||||
eat_whitespace(p, os, parent_context, false);
|
eat_whitespace(p, os, parent_context, false);
|
||||||
@ -825,6 +842,16 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
}
|
}
|
||||||
p.popPosition();
|
p.popPosition();
|
||||||
}
|
}
|
||||||
|
// if only \makebox{content} was used we can its width to 1\width
|
||||||
|
// because this identic and also identic to \mbox
|
||||||
|
// this doesn't work for \framebox{content}, thus we have to use ERT for this
|
||||||
|
if (latex_width.empty() && inner_type == "makebox") {
|
||||||
|
width_value = "1";
|
||||||
|
width_unit = "in";
|
||||||
|
width_special = "width";
|
||||||
|
} else if (latex_width.empty() && outer_type == "framebox") {
|
||||||
|
use_ert = true;
|
||||||
|
}
|
||||||
if (use_ert) {
|
if (use_ert) {
|
||||||
ostringstream ss;
|
ostringstream ss;
|
||||||
if (!outer_type.empty()) {
|
if (!outer_type.empty()) {
|
||||||
@ -873,6 +900,9 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
if (outer_flags & FLAG_END)
|
if (outer_flags & FLAG_END)
|
||||||
handle_ert(os, "\\end{" + outer_type + '}',
|
handle_ert(os, "\\end{" + outer_type + '}',
|
||||||
parent_context);
|
parent_context);
|
||||||
|
else if (inner_type.empty() && outer_type == "framebox")
|
||||||
|
// in this case it is already closed later
|
||||||
|
;
|
||||||
else
|
else
|
||||||
handle_ert(os, "}", parent_context);
|
handle_ert(os, "}", parent_context);
|
||||||
}
|
}
|
||||||
@ -883,8 +913,6 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
position = "c";
|
position = "c";
|
||||||
if (inner_pos.empty())
|
if (inner_pos.empty())
|
||||||
inner_pos = position;
|
inner_pos = position;
|
||||||
// FIXME: Support makebox
|
|
||||||
bool const use_makebox = false;
|
|
||||||
parent_context.check_layout(os);
|
parent_context.check_layout(os);
|
||||||
begin_inset(os, "Box ");
|
begin_inset(os, "Box ");
|
||||||
if (outer_type == "framed")
|
if (outer_type == "framed")
|
||||||
@ -910,9 +938,9 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
os << "inner_pos \"" << inner_pos << "\"\n";
|
os << "inner_pos \"" << inner_pos << "\"\n";
|
||||||
os << "use_parbox " << (inner_type == "parbox" || shadedparbox)
|
os << "use_parbox " << (inner_type == "parbox" || shadedparbox)
|
||||||
<< '\n';
|
<< '\n';
|
||||||
os << "use_makebox " << use_makebox << '\n';
|
os << "use_makebox " << (inner_type == "makebox") << '\n';
|
||||||
os << "width \"" << width_value << width_unit << "\"\n";
|
os << "width \"" << width_value << width_unit << "\"\n";
|
||||||
os << "special \"none\"\n";
|
os << "special \"" << width_special << "\"\n";
|
||||||
os << "height \"" << height_value << height_unit << "\"\n";
|
os << "height \"" << height_value << height_unit << "\"\n";
|
||||||
os << "height_special \"" << height_special << "\"\n";
|
os << "height_special \"" << height_special << "\"\n";
|
||||||
os << "status open\n\n";
|
os << "status open\n\n";
|
||||||
@ -921,9 +949,8 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
// InsetBox::forcePlainLayout() is hard coded and does not
|
// InsetBox::forcePlainLayout() is hard coded and does not
|
||||||
// use the inset layout. Apart from that do we call parse_text
|
// use the inset layout. Apart from that do we call parse_text
|
||||||
// up to two times, but need only one check_end_layout.
|
// up to two times, but need only one check_end_layout.
|
||||||
|
|
||||||
bool const forcePlainLayout =
|
bool const forcePlainLayout =
|
||||||
(!inner_type.empty() || use_makebox) &&
|
(!inner_type.empty() || inner_type == "makebox") &&
|
||||||
outer_type != "shaded" && outer_type != "framed";
|
outer_type != "shaded" && outer_type != "framed";
|
||||||
Context context(true, parent_context.textclass);
|
Context context(true, parent_context.textclass);
|
||||||
if (forcePlainLayout)
|
if (forcePlainLayout)
|
||||||
@ -3528,13 +3555,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
//\makebox{} will be parsed by parse_box when bug 2956 is fixed
|
//\makebox{} will be parsed by parse_box when bug 2956 is fixed
|
||||||
else if (t.cs() == "makebox") {
|
else if (t.cs() == "makebox") {
|
||||||
string arg = t.asInput();
|
string arg = t.asInput();
|
||||||
if (p.next_token().character() == '(')
|
if (p.next_token().character() == '(') {
|
||||||
//the syntax is: \makebox(x,y)[position]{content}
|
//the syntax is: \makebox(x,y)[position]{content}
|
||||||
arg += p.getFullParentheseArg();
|
arg += p.getFullParentheseArg();
|
||||||
else
|
|
||||||
//the syntax is: \makebox[width][position]{content}
|
|
||||||
arg += p.getFullOpt();
|
arg += p.getFullOpt();
|
||||||
handle_ert(os, arg + p.getFullOpt(), context);
|
handle_ert(os, arg + p.get_token().asInput(), context);
|
||||||
|
} else
|
||||||
|
//the syntax is: \makebox[width][position]{content}
|
||||||
|
parse_box(p, os, 0, FLAG_ITEM, outer, context,
|
||||||
|
"", "", t.cs());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "smallskip" ||
|
else if (t.cs() == "smallskip" ||
|
||||||
|
Loading…
Reference in New Issue
Block a user