tex2lyx: support relative lengths in \vspace and \hspace

This commit is contained in:
Uwe Stöhr 2014-11-23 04:56:47 +01:00
parent a9f9b29229
commit 489cdae255
4 changed files with 27 additions and 9 deletions

View File

@ -36,7 +36,6 @@ Format LaTeX feature LyX feature
358 custom makeindex command \index_command
363 horizontal longtable alignment InsetTabular
364 branch file name suffix \filename_suffix
367 relative lengths for h and v space InsetSpace, InsetVSpace
368 glue lengths InsetSpace
371 automatic mhchem loading \use_mhchem
375 \includeonly \{begin,end}_includeonly

View File

@ -1694,9 +1694,14 @@ in the middle. Lines can have a downbrace fill
\end_inset
in the middle. Lines can have space
in the middle. Lines can have absolute space
\begin_inset space \hspace{}
\length 2cm
\end_inset
in the middle. Lines can have relative space
\begin_inset space \hspace{}
\length 12text%
\end_inset
in the middle. Lines can have protected space
@ -2006,8 +2011,12 @@ in the middle. Lines can have a vfill
\begin_inset VSpace vfill*
\end_inset
in the middle. Lines can have vertical space
in the middle. Lines can have vertical absolute space
\begin_inset VSpace 2cm
\end_inset
in the middle. Lines can have vertical relative space
\begin_inset VSpace 9col%
\end_inset
in the middle. Lines can have protected vertical space

View File

@ -357,7 +357,8 @@ Lines can have a left arrow fill \leftarrowfill in the middle.
Lines can have a right arrow fill \rightarrowfill in the middle.
Lines can have a upbrace fill \upbracefill in the middle.
Lines can have a downbrace fill \downbracefill in the middle.
Lines can have space \hspace{2cm} in the middle.
Lines can have absolute space \hspace{2cm} in the middle.
Lines can have relative space \hspace{0.12\textwidth} in the middle.
Lines can have protected space \hspace*{2cm} in the middle.
We also handle defined spaces:
@ -421,7 +422,8 @@ interword: $a\ b$
Lines can have a vfill \vfill in the middle.
Lines can have a vfill \vspace{\fill} in the middle.
Lines can have a protected vfill \vspace*{\fill} in the middle.
Lines can have vertical space \vspace{2cm} in the middle.
Lines can have vertical absolute space \vspace{2cm} in the middle.
Lines can have vertical relative space \vspace{0.09\columnwidth} in the middle.
Lines can have protected vertical space \vspace*{2cm} in the middle.
We also handle skips:

View File

@ -4395,8 +4395,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
case Length::MU:
known_unit = true;
break;
default:
default: {
//unitFromString(unit) fails for relative units like Length::PCW
// therefore handle them separately
if (unit == "\\paperwidth" || unit == "\\columnwidth"
|| unit == "\\textwidth" || unit == "\\linewidth"
|| unit == "\\textheight" || unit == "\\paperheight")
known_unit = true;
break;
}
}
}
}
@ -4420,9 +4427,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
// Literal vertical length or known variable
context.check_layout(os);
begin_inset(os, "VSpace ");
if (known_unit)
os << value;
os << unit;
if (known_vspace)
os << unit;
if (known_unit && !known_vspace)
os << translate_len(length);
if (starred)
os << '*';
end_inset(os);