]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added with_header to the write_tex method.
authorluca <luca@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 29 Oct 2004 14:34:49 +0000 (14:34 +0000)
committerluca <luca@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 29 Oct 2004 14:34:49 +0000 (14:34 +0000)
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
deal.II/base/source/table_handler.cc

index cb114ef3f17a2daecc0dc7b1981bdc0c7301ba99..5527bb1a01d47970ab8df610f95ff1874ca00d1c 100644 (file)
@@ -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
+                                      * <tt>table</tt> for tex output. 
+                                      */
+    void set_tex_table_caption (const std::string &table_caption);
+
+                                     /**
+                                      * Sets the label of this
+                                      * <tt>table</tt> for tex output. 
+                                      */
+    void set_tex_table_label (const std::string &table_label);
+
                                      /**
                                       * Sets the caption the the
                                       * supercolumn <tt>superkey</tt> 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
                                       * <tt>set_tex_supercaptions(...)</tt>.
                                       */
     std::map<std::string, std::string> tex_supercaptions;
+
+                                     /**
+                                      * The caption of the table itself.
+                                     */
+    std::string tex_table_caption;
+                                     /**
+                                      * The label of the table.
+                                     */
+    std::string tex_table_label; 
+    
 };
 
 
index fe02a13d88a2ddff01985acd17c081477a2d1b2f..fa684070b404a8f15f026ad83ff7a76d4d8c87e5 100644 (file)
@@ -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;
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.