From 1cd3c137a47dfc72ad0a0e524e9c5e3f40072f61 Mon Sep 17 00:00:00 2001 From: luca Date: Fri, 29 Oct 2004 14:34:49 +0000 Subject: [PATCH] Added with_header to the write_tex method. Added two new functions: set_tex_table_caption and set_tex_table_label. git-svn-id: https://svn.dealii.org/trunk@9738 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/table_handler.h | 35 ++++++++++++++++++++-- deal.II/base/source/table_handler.cc | 36 +++++++++++++++-------- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/deal.II/base/include/base/table_handler.h b/deal.II/base/include/base/table_handler.h index cb114ef3f1..5527bb1a01 100644 --- a/deal.II/base/include/base/table_handler.h +++ b/deal.II/base/include/base/table_handler.h @@ -278,6 +278,18 @@ class TableHandler void set_tex_caption (const std::string &key, const std::string &tex_caption); + /** + * Sets the tex caption of the entire + * table for tex output. + */ + void set_tex_table_caption (const std::string &table_caption); + + /** + * Sets the label of this + * table for tex output. + */ + void set_tex_table_label (const std::string &table_label); + /** * Sets the caption the the * supercolumn superkey for @@ -309,9 +321,18 @@ class TableHandler void write_text (std::ostream &out) const; /** - * Write table as a tex file. + * Write table as a tex file. If + * with_header is set to false + * (it is true by default), then + * no \documentclass{...}, + * \begin{document} and + * \end{document} are used. In + * this way the file can be + * included into an existing tex + * file using a command like + * "\input{table_file}". */ - void write_tex (std::ofstream &file) const; + void write_tex (std::ofstream &file, const bool with_header=true) const; /** @addtogroup Exceptions * @{ */ @@ -506,6 +527,16 @@ class TableHandler * set_tex_supercaptions(...). */ std::map tex_supercaptions; + + /** + * The caption of the table itself. + */ + std::string tex_table_caption; + /** + * The label of the table. + */ + std::string tex_table_label; + }; diff --git a/deal.II/base/source/table_handler.cc b/deal.II/base/source/table_handler.cc index fe02a13d88..fa684070b4 100644 --- a/deal.II/base/source/table_handler.cc +++ b/deal.II/base/source/table_handler.cc @@ -192,6 +192,15 @@ void TableHandler::set_tex_caption (const std::string &key, columns[key].tex_caption=tex_caption; } +void TableHandler::set_tex_table_caption (const std::string &table_caption) +{ + tex_table_caption=table_caption; +} + +void TableHandler::set_tex_table_label (const std::string &table_label) +{ + tex_table_label=table_label; +} void TableHandler::set_tex_supercaption (const std::string &superkey, const std::string &tex_supercaption) @@ -344,14 +353,15 @@ void TableHandler::write_text(std::ostream &out) const } -void TableHandler::write_tex (std::ofstream &out) const +void TableHandler::write_tex (std::ofstream &out, const bool with_header) const { AssertThrow (out, ExcIO()); + if (with_header) + out << "\\documentclass[10pt]{report}" << std::endl + << "\\usepackage{float}" << std::endl << std::endl << std::endl + << "\\begin{document}" << std::endl; - out << "\\documentclass[10pt]{report}" << std::endl - << "\\usepackage{float}" << std::endl << std::endl << std::endl - << "\\begin{document}" << std::endl - << "\\begin{table}[H]" << std::endl + out << "\\begin{table}[H]" << std::endl << "\\begin{center}" << std::endl << "\\begin{tabular}{|"; @@ -451,13 +461,15 @@ void TableHandler::write_tex (std::ofstream &out) const out << "\\\\ \\hline" << std::endl; } - std::string caption="table"; - - out << "\\end{tabular}" << std::endl - << "\\end{center}" << std::endl -// << "\\caption{" << caption << "}" << std::endl - << "\\end{table}" << std::endl - << "\\end{document}" << std::endl; + out << "\\end{tabular}" << std::endl + << "\\end{center}" << std::endl; + if(tex_table_caption!="") + out << "\\caption{" << tex_table_caption << "}" << std::endl; + if(tex_table_label!="") + out << "\\label{" << tex_table_label << "}" << std::endl; + out << "\\end{table}" << std::endl; + if (with_header) + out << "\\end{document}" << std::endl; } -- 2.39.5