write Latex model: added automatic line breaks with breqn Latex package

issue#70
Michel Juillard 2011-10-09 18:24:39 +02:00
parent b9c9b784a1
commit 9a4f9203b6
1 changed files with 5 additions and 4 deletions

View File

@ -1327,6 +1327,7 @@ ModelTree::writeLatexModelFile(const string &filename, ExprNodeOutputType output
output << "\\documentclass[10pt,a4paper]{article}" << endl output << "\\documentclass[10pt,a4paper]{article}" << endl
<< "\\usepackage[landscape]{geometry}" << endl << "\\usepackage[landscape]{geometry}" << endl
<< "\\usepackage{fullpage}" << endl << "\\usepackage{fullpage}" << endl
<< "\\usepackage{breqn}" << endl
<< "\\begin{document}" << endl << "\\begin{document}" << endl
<< "\\footnotesize" << endl; << "\\footnotesize" << endl;
@ -1337,20 +1338,20 @@ ModelTree::writeLatexModelFile(const string &filename, ExprNodeOutputType output
int id = it->first; int id = it->first;
expr_t value = it->second; expr_t value = it->second;
output << "\\begin{equation*}" << endl output << "\\begin{dmath*}" << endl
<< symbol_table.getName(id) << " = "; << symbol_table.getName(id) << " = ";
// Use an empty set for the temporary terms // Use an empty set for the temporary terms
value->writeOutput(output, output_type); value->writeOutput(output, output_type);
output << endl << "\\end{equation*}" << endl; output << endl << "\\end{dmath*}" << endl;
} }
for (int eq = 0; eq < (int) equations.size(); eq++) for (int eq = 0; eq < (int) equations.size(); eq++)
{ {
output << "\\begin{equation}" << endl output << "\\begin{dmath}" << endl
<< "% Equation " << eq+1 << endl; << "% Equation " << eq+1 << endl;
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found // Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(output, output_type); dynamic_cast<ExprNode *>(equations[eq])->writeOutput(output, output_type);
output << endl << "\\end{equation}" << endl; output << endl << "\\end{dmath}" << endl;
} }
output << "\\end{document}" << endl; output << "\\end{document}" << endl;