From 4d92baaf29c45777f4fe8af51c1ef0844e6f7a11 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Tue, 5 Jun 2018 14:47:36 +0200
Subject: [PATCH] Clean up writing of equation tags in latex file

---
 src/ModelTree.cc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 379728dc..bb7c84fd 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1695,9 +1695,9 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
   for (int eq = 0; eq < (int) equations.size(); eq++)
     {
       content_output << "% Equation " << eq + 1 << endl;
-      bool wrote_eq_tag = false;
       if (write_equation_tags)
         {
+          bool wrote_eq_tag = false;
           for (const auto & equation_tag : equation_tags)
             if (equation_tag.first == eq)
               {
@@ -1713,9 +1713,10 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
 
                 wrote_eq_tag = true;
               }
+
+          if (wrote_eq_tag)
+            content_output << "]";
         }
-      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
-- 
GitLab