CbmRoot
Loading...
Searching...
No Matches
CbmLatexReportElement.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev, Andrey Lebedev [committer] */
4
11
12#include <sstream> // for string, operator<<, basic_ostream, endl
13#include <string> // for operator+, char_traits, operator!=
14
15using std::endl;
16using std::string;
17using std::stringstream;
18using std::vector;
19
21
23
24string CbmLatexReportElement::TableBegin(const string& caption, const vector<string>& colNames) const
25{
26 string st = "\\begin{table}[h] \n";
27 st += "\\centering";
28 if (caption != "") st += "\\caption{" + caption + "} \n";
29 st += "\\begin{tabular}{|";
30 for (unsigned int i = 0; i < colNames.size(); i++) {
31 st += "c|";
32 }
33 st += "} \\hline \n";
34 // names start from the second column
35 for (unsigned int i = 0; i < colNames.size(); i++) {
36 st += (i < (colNames.size() - 1)) ? (colNames[i] + " & ") : (colNames[i]);
37 }
38 st += "\\\\ \\hline \n";
39 return st;
40}
41
42string CbmLatexReportElement::TableEnd() const { return "\\end{tabular} \\end{table}"; }
43
44string CbmLatexReportElement::TableEmptyRow(int nofCols, const string& name) const
45{
46 stringstream ss;
47 ss << "\\multicolumn{" << nofCols << "}{|c|}{" << name << "} \\\\ \\hline" << endl;
48 return ss.str();
49}
50
51string CbmLatexReportElement::TableRow(const vector<string>& row) const
52{
53 string st;
54 for (unsigned int i = 0; i < row.size(); i++) {
55 st += (i < (row.size() - 1)) ? (row[i] + " & ") : (row[i]);
56 }
57 st += " \\\\ \\hline \n";
58 return st;
59}
60
61string CbmLatexReportElement::Image(const string& title, const string& file) const
62{
63 stringstream ss;
64
65 ss << "\\begin{figure}[h]" << endl;
66 ss << "\\centering" << endl;
67 ss << "\\includegraphics[width=7cm]{" << file << ".eps}" << endl;
68 ss << "\\caption{" << title << "}" << endl;
69 ss << "\\end{figure}" << endl;
70 return ss.str();
71}
72
74{
75 string str = "\\documentclass[a4paper,14pt]{article}";
76 str += "\\usepackage{amssymb}";
77 str += "\\setlength\\oddsidemargin{-2cm}";
78 str += "\\setlength\\evensidemargin{-2cm}";
79 str += "\\setlength\\textwidth{17cm}";
80 str += "\\setlength\\topmargin{0cm}";
81 str += "\\usepackage[dvips]{graphicx}";
82 str += "\\begin{document}";
83
84 return str;
85}
86
87string CbmLatexReportElement::DocumentEnd() const { return "\\end{document}"; }
88
89string CbmLatexReportElement::Title(int size, const string& title) const
90{
91 string st = "\\";
92 for (int i = 0; i < size; i++)
93 st += "sub";
94 st += "title{" + title + "}";
95 return st;
96}
97
ClassImp(CbmConverterManager)
Implementation of CbmReportElement for Latex output.
static constexpr size_t size()
Definition KfSimdPseudo.h:2
Implementation of CbmLitReportElement for Latex output.
virtual std::string TableEmptyRow(int nofCols, const std::string &name) const
Inherited from CbmReportElement.
virtual std::string Image(const std::string &title, const std::string &file) const
Inherited from CbmReportElement.
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const
Inherited from CbmReportElement.
virtual std::string TableEnd() const
Inherited from CbmReportElement.
virtual ~CbmLatexReportElement()
Destructor.
virtual std::string Title(int size, const std::string &title) const
Inherited from CbmReportElement.
virtual std::string DocumentEnd() const
Inherited from CbmReportElement.
virtual std::string TableRow(const std::vector< std::string > &row) const
Inherited from CbmReportElement.
virtual std::string DocumentBegin() const
Inherited from CbmReportElement.