tex2lyx/text.cpp: support for lengths like "2.5\width" in boxes

LyX supports these length in boxes for a while now; tex2lyx was not up to date
This commit is contained in:
Uwe Stöhr 2015-05-18 01:37:59 +02:00
parent 7eaae7b7ff
commit 496dba4532
2 changed files with 20 additions and 5 deletions

View File

@ -97,6 +97,10 @@ blabla \makebox[3cm]{makebox 2} blabla
blabla \makebox[3cm][l]{makebox 3} blabla
\makebox[1\width]{www}
\parbox[t][1\depth]{2.3cm}{www}
\begin{figure}[ht]
\centering
\setlength{\unitlength}{.2in}
@ -126,6 +130,8 @@ blabla \framebox[3cm]{framebox 2} blabla
blabla \framebox[3cm][l]{framebox 3} blabla
\framebox[1.5\totalheight]{www}
This is an example text. %
\framebox{%
\begin{minipage}[c][1\totalheight][s]{0.2\columnwidth}%

View File

@ -998,9 +998,8 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
if (!outer_type.empty() && !inner_type.empty() &&
(inner_flags & FLAG_END))
active_environments.push_back(inner_type);
// LyX can't handle length variables
bool use_ert = contains(width_unit, '\\') || contains(height_unit, '\\');
if (!use_ert && !outer_type.empty() && !inner_type.empty()) {
bool use_ert = false;
if (!outer_type.empty() && !inner_type.empty()) {
// Look whether there is some content after the end of the
// inner box, but before the end of the outer box.
// If yes, we need to output ERT.
@ -1130,10 +1129,20 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
os << "use_makebox " << (inner_type == "makebox") << '\n';
if (outer_type == "fbox" || outer_type == "mbox")
os << "width \"\"\n";
// for values like "1.5\width" LyX uses "1.5in" as width ad sets "width" as sepecial
else if (contains(width_unit, '\\'))
os << "width \"" << width_value << "in" << "\"\n";
else
os << "width \"" << width_value << width_unit << "\"\n";
os << "special \"" << width_special << "\"\n";
os << "height \"" << height_value << height_unit << "\"\n";
if (contains(width_unit, '\\')) {
width_unit.erase (0,1); // remove the leading '\'
os << "special \"" << width_unit << "\"\n";
} else
os << "special \"" << width_special << "\"\n";
if (contains(height_unit, '\\'))
os << "height \"" << height_value << "in" << "\"\n";
else
os << "height \"" << height_value << height_unit << "\"\n";
os << "height_special \"" << height_special << "\"\n";
os << "thickness \"" << thickness << "\"\n";
os << "separation \"" << separation << "\"\n";