- if (footnotekind != LyXParagraph::FOOTNOTE
- && footnotekind != LyXParagraph::MARGIN
- && file.length()
- && !suffixIs(file, '\n')) {
- // we need to ensure that real floats like tables and figures
- // have their \begin{} on a new line otherwise we can get
- // incorrect results when using the endfloat.sty package
- // especially if two floats follow one another. ARRae 981022
- // NOTE: if the file is length 0 it must have just been
- // written out so we assume it ended with a '\n'
- file += '\n';
- texrow.newline();
- }
-
- BufferParams * params = ¤t_view->buffer()->params;
- bool footer_in_body = true;
- switch (footnotekind) {
- case LyXParagraph::FOOTNOTE:
- if (style.intitle) {
- file += "\\thanks{\n";
- footer_in_body = false;
- } else {
- if (foot_count == -1) {
- // we're at depth 0 so we can use:
- file += "\\footnote{%\n";
- footer_in_body = false;
- } else {
- file += "\\footnotemark{}%\n";
- if (foot_count) {
- // we only need this when there are
- // multiple footnotes
- foot += "\\stepcounter{footnote}";
- }
- foot += "\\footnotetext{%\n";
- foot_texrow.start(this, 0);
- foot_texrow.newline();
- ++foot_count;
- }
- }
- break;
- case LyXParagraph::MARGIN:
- file += "\\marginpar{\n";
- break;
- case LyXParagraph::FIG:
- if (pextra_type == PEXTRA_FLOATFLT
- && (!pextra_width.empty()
- || !pextra_widthp.empty())) {
- char bufr[80];
- if (!pextra_width.empty())
- sprintf(bufr, "\\begin{floatingfigure}{%s}\n",
- pextra_width.c_str());
- else
- sprintf(bufr,
- "\\begin{floatingfigure}{%f\\textwidth}\n",
- atoi(pextra_widthp.c_str())/100.0);
- file += bufr;
- } else {
- file += "\\begin{figure}";
- if (!params->float_placement.empty()) {
- file += '[';
- file += params->float_placement;
- file += "]\n";
- } else {
- file += '\n';
- }
- }
- break;
- case LyXParagraph::TAB:
- file += "\\begin{table}";
- if (!params->float_placement.empty()) {
- file += '[';
- file += params->float_placement;
- file += "]\n";
- } else {
- file += '\n';
- }
- break;
- case LyXParagraph::WIDE_FIG:
- file += "\\begin{figure*}";
- if (!params->float_placement.empty()) {
- file += '[';
- file += params->float_placement;
- file += "]\n";
- } else {
- file += '\n';
- }
- break;
- case LyXParagraph::WIDE_TAB:
- file += "\\begin{table*}";
- if (!params->float_placement.empty()) {
- file += '[';
- file += params->float_placement;
- file += "]\n";
- } else {
- file += '\n';
- }
- break;
- case LyXParagraph::ALGORITHM:
- file += "\\begin{algorithm}\n";
- break;
- }
- texrow.newline();
-
- if (footnotekind != LyXParagraph::FOOTNOTE
- || !footer_in_body) {
- // Process text for all floats except footnotes in body
- do {
- LyXLayout const & style =
- textclasslist.Style(current_view->buffer()->params.textclass,
- par->layout);
- if (par->IsDummy())
- lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
- << endl;
- if (style.isEnvironment()
- || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
- // Allows the use of minipages within float
- // environments. Shouldn't be circular because
- // we don't support footnotes inside
- // floats (yet). ARRae
- par = par->TeXEnvironment(file, texrow,
- foot, foot_texrow,
- foot_count);
- } else {
- par = par->TeXOnePar(file, texrow,
- foot, foot_texrow,
- foot_count);
- }
-
- if (par && !par->IsDummy() && par->depth > depth) {
- par = par->TeXDeeper(file, texrow,
- foot, foot_texrow,
- foot_count);
- }
- } while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE);
- } else {
- // process footnotes > depth 0 or in environments separately
- // NOTE: Currently don't support footnotes within footnotes
- // even though that is possible using the \footnotemark
- string dummy;
- TexRow dummy_texrow;
- int dummy_count = 0;
- do {
- LyXLayout const & style =
- textclasslist.Style(current_view->buffer()->params.textclass,
- par->layout);
- if (par->IsDummy())
- lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
- << endl;
- if (style.isEnvironment()
- || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
- // Allows the use of minipages within float
- // environments. Shouldn't be circular because
- // we don't support footnotes inside
- // floats (yet). ARRae
- par = par->TeXEnvironment(foot, foot_texrow,
- dummy, dummy_texrow,
- dummy_count);
- } else {
- par = par->TeXOnePar(foot, foot_texrow,
- dummy, dummy_texrow,
- dummy_count);
- }