Increase tex2lyx output format to 334.

331:     Set the caption flag for longtable caption rows
332:     Nothing to do (empty lyx2lyx conversion)
333:     Nothing to do (tex2lyx did already use the new style names because it
         uses the current layout files)
334:     Nothing to do (tex2lyx did already produce the new format, since it
         used the LaTeX paper names also in the output and did not suffer from
	 bug 4868)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37012 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2010-12-27 18:10:23 +00:00
parent 6da25359f0
commit 5247a0ed1c
3 changed files with 143 additions and 2 deletions

View File

@ -72,7 +72,7 @@ enum LTRowType
class RowInfo {
public:
RowInfo() : topline(false), bottomline(false), type(LT_NORMAL),
newpage(false) {}
caption(false), newpage(false) {}
/// horizontal line above
bool topline;
/// horizontal line below
@ -80,6 +80,8 @@ public:
/// These are for longtabulars only
/// row type (head, foot, firsthead etc.)
LTRowType type;
/// row for a caption
bool caption;
/// row for a newpage
bool newpage;
};
@ -1001,6 +1003,35 @@ void handle_tabular(Parser & p, ostream & os, bool is_long_tabular,
cellinfo[row][col].align = 'c';
}
} else if (col == 0 && is_long_tabular &&
p.next_token().cs() == "caption") {
// longtable caption support in LyX is a hack:
// Captions require a row of their own with
// the caption flag set to true, having only
// one multicolumn cell. The contents of that
// cell must contain exactly one caption inset
// and nothing else.
rowinfo[row].caption = true;
for (size_t c = 1; c < cells.size(); ++c) {
if (!cells[c].empty()) {
cerr << "Moving cell content '"
<< cells[c]
<< "' into the caption cell. "
"This will probably not work."
<< endl;
cells[0] += cells[c];
}
}
cells.resize(1);
cellinfo[row][col].align = colinfo[col].align;
cellinfo[row][col].multi = CELL_BEGIN_OF_MULTICOLUMN;
ostringstream os;
parse_text_in_inset(p, os, FLAG_CELL, false, context);
cellinfo[row][col].content += os.str();
// add dummy multicolumn cells
for (size_t c = 1; c < colinfo.size(); ++c)
cellinfo[row][c].multi = CELL_PART_OF_MULTICOLUMN;
} else {
cellinfo[row][col].leftlines = colinfo[col].leftlines;
cellinfo[row][col].rightlines = colinfo[col].rightlines;
@ -1100,6 +1131,7 @@ void handle_tabular(Parser & p, ostream & os, bool is_long_tabular,
<< write_attribute("endlastfoot",
rowinfo[row].type == LT_LASTFOOT)
<< write_attribute("newpage", rowinfo[row].newpage)
<< write_attribute("caption", rowinfo[row].caption)
<< ">\n";
for (size_t col = 0; col < colinfo.size(); ++col) {
CellInfo const & cell = cellinfo[row][col];

View File

@ -21,6 +21,8 @@
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{doc}
\usepackage{longtable}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\newcommand{\lyxline}[1][1pt]{%
@ -123,6 +125,113 @@ There is also some basic support for graphics, in the form
\includegraphics{foo.eps}, or the slightly more elaborate
\includegraphics[bb=10bp 0bp 96bp 96bp,clip,height=1cm, width=1cm]{foo.eps}.
\section{Tables\index{Tables}}
The following example is stolen from the longtable documentation.
\let\package\textsf
\let\env\textsf
\providecommand\finalclearpage{\clearpage}
\DeleteShortVerb{\|}
\MakeShortVerb{\"}
\def\v{\char`}
\begin{longtable}{@{*}r||p{1in}@{*}}
KILLED & LINE!!!! \kill
\caption
[An optional table caption (used in the list of tables)]
{A long table\label{long}}\\
\hline\hline
\multicolumn{2}{@{*}c@{*}}%
{This part appears at the top of the table}\\
\textsc{First}&\textsc{Second}\\
\hline\hline
\endfirsthead
\caption[]{(continued)}\\
\hline\hline
\multicolumn{2}{@{*}c@{*}}%
{This part appears at the top of every other page}\\
\textbf{First}&\textbf{Second}\\
\hline\hline
\endhead
\hline
This goes at the&bottom.\\
\hline
\endfoot
\hline
These lines will&appear\\
in place of the & usual foot\\
at the end& of the table\\
\hline
\endlastfoot
\env{longtable} columns are specified& in the \\
same way as in the \env{tabular}& environment.\\
"@{*}r||p{1in}@{*}"& in this case.\\
Each row ends with a& "\\" command.\\
The "\\" command has an& optional\\
argument, just as in& the\\
\env{tabular}&environment.\\[10pt]
See the effect of "\\[10pt]"&?\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Also "\hline" may be used,& as in \env{tabular}.\\
\hline
That was a "\hline"&.\\
\hline\hline
That was "\hline\hline"&.\\
\multicolumn{2}{||c||}%
{This is a \ttfamily\v\\multicolumn\v{2\v}\v{||c||\v}}\\
If a page break occurs at a "\hline" then& a line is drawn\\
at the bottom of one page and at the& top of the next.\\
\hline
The "[t] [b] [c]" argument of \env{tabular}& can not be used.\\
The optional argument may be one of& "[l] [r] [c]"\\
to specify whether the table should be& adjusted\\
to the left, right& or centrally.\\
\hline\hline
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Some lines may take up a lot of space, like this: &
\raggedleft This last column is a ``p'' column so this
``row'' of the table can take up several lines. Note however that
\TeX\ will never break a page within such a row. Page breaks only
occur between rows of the table or at "\hline" commands.
\tabularnewline
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
Lots of lines& like this.\\
\hline
Lots\footnote{This is a footnote.} of lines& like this.\\
Lots of lines& like this\footnote{\env{longtable} takes special
precautions, so that footnotes may also be used in `p' columns.}\\
\hline
Lots of lines& like this.\\
Lots of lines& like this.
\end{longtable}
\section{Macros}
LyX supports several kinds of macros:

View File

@ -114,7 +114,7 @@ extern CommandMap known_math_environments;
///
extern bool noweb_mode;
/// LyX format that is created by tex2lyx
int const LYX_FORMAT = 330;
int const LYX_FORMAT = 334;
/// path of the master .tex file
extern std::string getMasterFilePath();