Import table cells in turn environment.

This is a part of bug #8081: Translate cells in
\begin{turn}{number}...\end{turn} to native syntax.
This commit is contained in:
Georg Baum 2012-05-06 19:12:51 +02:00
parent c90e02ff0d
commit cd691081b4
2 changed files with 23 additions and 7 deletions

View File

@ -209,6 +209,14 @@ string const write_attribute(string const & name, string const & s)
} }
string const write_attribute(string const & name, int const & i)
{
// we write only true attribute values so we remove a bit of the
// file format bloat for tabulars.
return i ? write_attribute(name, convert<string>(i)) : string();
}
/*! rather brutish way to code table structure in a string: /*! rather brutish way to code table structure in a string:
\verbatim \verbatim
@ -1194,18 +1202,24 @@ void handle_tabular(Parser & p, ostream & os, string const & name,
for (size_t c = 1; c < colinfo.size(); ++c) for (size_t c = 1; c < colinfo.size(); ++c)
cellinfo[row][c].multi = CELL_PART_OF_MULTICOLUMN; cellinfo[row][c].multi = CELL_PART_OF_MULTICOLUMN;
} else { } else {
bool sideways = false; bool turn = false;
int rotate = 0;
if (p.next_token().cs() == "begin") { if (p.next_token().cs() == "begin") {
p.pushPosition(); p.pushPosition();
p.get_token(); p.get_token();
string const env = p.getArg('{', '}'); string const env = p.getArg('{', '}');
if (env == "sideways") { if (env == "sideways" || env == "turn") {
string angle = "90";
if (env == "turn") {
turn = true;
angle = p.getArg('{', '}');
}
active_environments.push_back(env); active_environments.push_back(env);
p.verbatimEnvironment(env); p.verbatimEnvironment(env);
active_environments.pop_back(); active_environments.pop_back();
p.skip_spaces(); p.skip_spaces();
if (!p.good()) if (!p.good() && support::isStrInt(angle))
sideways = true; rotate = convert<int>(angle);
} }
p.popPosition(); p.popPosition();
} }
@ -1213,10 +1227,12 @@ void handle_tabular(Parser & p, ostream & os, string const & name,
cellinfo[row][col].rightlines = colinfo[col].rightlines; cellinfo[row][col].rightlines = colinfo[col].rightlines;
cellinfo[row][col].align = colinfo[col].align; cellinfo[row][col].align = colinfo[col].align;
ostringstream os; ostringstream os;
if (sideways) { if (rotate != 0) {
cellinfo[row][col].rotate = 90; cellinfo[row][col].rotate = rotate;
p.get_token(); p.get_token();
active_environments.push_back(p.getArg('{', '}')); active_environments.push_back(p.getArg('{', '}'));
if (turn)
p.getArg('{', '}');
parse_text_in_inset(p, os, FLAG_END, false, context); parse_text_in_inset(p, os, FLAG_END, false, context);
active_environments.pop_back(); active_environments.pop_back();
preamble.registerAutomaticallyLoadedPackage("rotating"); preamble.registerAutomaticallyLoadedPackage("rotating");

View File

@ -376,7 +376,7 @@ A table*:
\begin{tabular*} % some comment \begin{tabular*} % some comment
{0.8\columnwidth}[b]{lr} {0.8\columnwidth}[b]{lr}
two\\ two\\
lonely&\begin{sideways}lines\end{sideways} \begin{turn}{-50}lonely\end{turn}&\begin{sideways}lines\end{sideways}
\end{tabular*} \end{tabular*}
A booktabs table: A booktabs table: