From 5021601b5b88af63a80a2da0f1362a0dacebe35b Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 5 Apr 2017 10:28:37 +0200 Subject: [PATCH] preprocessor: move equation tags out of dmath mode, include all equation tags in one set of brackets, allow equation tags to be interpreted as latex, modify manual and test accordingly. #477 --- ModelTree.cc | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ModelTree.cc b/ModelTree.cc index deec8b72..ed5ecdbe 100644 --- a/ModelTree.cc +++ b/ModelTree.cc @@ -1573,19 +1573,31 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output for (int eq = 0; eq < (int) equations.size(); eq++) { - content_output << "\\begin{dmath}" << endl - << "% Equation " << eq+1 << endl; + content_output << "% Equation " << eq + 1 << endl; + bool wrote_eq_tag = false; if (write_equation_tags) - for (vector > >::const_iterator iteqt = equation_tags.begin(); - iteqt != equation_tags.end(); iteqt++) - if (iteqt->first == eq) - { - content_output << "[\\textrm{" << iteqt->second.first << "}"; - if (!empty(iteqt->second.second)) - content_output << " = \\textrm{``" << iteqt->second.second << "''}"; - content_output << "]"; - } + { + for (vector > >::const_iterator iteqt = equation_tags.begin(); + iteqt != equation_tags.end(); iteqt++) + if (iteqt->first == eq) + { + if (!wrote_eq_tag) + content_output << "\\noindent["; + else + content_output << ", "; + content_output << iteqt->second.first; + + if (!empty(iteqt->second.second)) + content_output << "= `" << iteqt->second.second << "'"; + + wrote_eq_tag = true; + } + } + if (wrote_eq_tag) + content_output << "]"; + + content_output << "\\begin{dmath}" << endl; // Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found dynamic_cast(equations[eq])->writeOutput(content_output, output_type); content_output << endl << "\\end{dmath}" << endl;