4242#include " importdata.h"
4343#include " reformat.h"
4444
45+
4546class SpLatex
4647{
4748public:
@@ -89,7 +90,12 @@ class SpLatex
8990 void multiplot (size_t ln, size_t indent, const std::string& cmdline);
9091
9192 // ! Process % TABULAR commands
92- void tabular (size_t ln, size_t indent, const std::string& cmdline);
93+ void tabular (size_t ln,
94+ size_t indent,
95+ const std::string& cmdline,
96+ const std::string& op_name,
97+ const std::string& separator,
98+ const std::string& endline);
9399
94100 // ! Process % DEFMACRO commands
95101 void defmacro (size_t ln, size_t indent, const std::string& cmdline);
@@ -381,7 +387,13 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
381387}
382388
383389// ! Process % TABULAR commands
384- void SpLatex::tabular (size_t ln, size_t indent, const std::string& cmdline)
390+ void SpLatex::tabular (
391+ size_t ln,
392+ size_t indent,
393+ const std::string& cmdline,
394+ const std::string& op_name,
395+ const std::string& separator,
396+ const std::string& endline)
385397{
386398 std::string query = cmdline;
387399
@@ -418,11 +430,11 @@ void SpLatex::tabular(size_t ln, size_t indent, const std::string& cmdline)
418430 std::ostringstream out;
419431 for (unsigned j = 0 ; j < sql->num_cols (); ++j)
420432 {
421- if (j != 0 ) out << " & " ;
433+ if (j != 0 ) out << separator ;
422434 out << std::setw (cwidth[j])
423435 << reformat.format (i, j, sql->text (i,j));
424436 }
425- out << " \\\\ " ;
437+ out << endline ;
426438 tlines.push_back (out.str ());
427439 }
428440
@@ -432,7 +444,7 @@ void SpLatex::tabular(size_t ln, size_t indent, const std::string& cmdline)
432444 ++eln;
433445
434446 static const boost::regex
435- re_endtabular (" [[:blank:]]*% END TABULAR .*" );
447+ re_endtabular (" [[:blank:]]*% END " + op_name + " .*" );
436448
437449 if (eln < m_lines.size () &&
438450 boost::regex_match (m_lines[eln], re_endtabular))
@@ -452,14 +464,14 @@ void SpLatex::tabular(size_t ln, size_t indent, const std::string& cmdline)
452464 ++rln;
453465 }
454466
455- tlines.push_back (shorten (" % END TABULAR " + query));
456- m_lines.replace (ln, eln+1 , indent, tlines, " TABULAR " );
467+ tlines.push_back (shorten (" % END " + op_name + " " + query));
468+ m_lines.replace (ln, eln+1 , indent, tlines, op_name );
457469 }
458470 else
459471 {
460472 // could not find END TABULAR: insert whole table.
461- tlines.push_back (shorten (" % END TABULAR " + query));
462- m_lines.replace (ln, ln, indent, tlines, " TABULAR " );
473+ tlines.push_back (shorten (" % END " + op_name + " " + query));
474+ m_lines.replace (ln, ln, indent, tlines, op_name );
463475 }
464476}
465477
@@ -564,7 +576,12 @@ SpLatex::SpLatex(TextLines& lines)
564576 else if (first_word == " TABULAR" )
565577 {
566578 OUT (ln << " % " << cmd);
567- tabular (ln, indent, cmd.substr (space_pos+1 ));
579+ tabular (ln, indent, cmd.substr (space_pos+1 ), " TABULAR" , " & " , " \\\\ " );
580+ }
581+ else if (first_word == " TABTABLE" )
582+ {
583+ OUT (ln << " % " << cmd);
584+ tabular (ln, indent, cmd.substr (space_pos+1 ), " TABTABLE" , " \t " , " " );
568585 }
569586 else if (first_word == " DEFMACRO" )
570587 {
0 commit comments