From 0988a1f755be01b00aab7a458c89d9b63800875d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 11 Jul 2019 17:33:53 +0200 Subject: [PATCH] Generated LaTeX files are now under /latex/ --- src/DynamicModel.cc | 4 ++-- src/ModelEquationBlock.cc | 9 +++++---- src/ModelTree.cc | 11 ++++++----- src/ModelTree.hh | 2 +- src/StaticModel.cc | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 2e60f33e..6d035dc0 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -6062,13 +6062,13 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con void DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const { - writeLatexModelFile(basename + "_dynamic", ExprNodeOutputType::latexDynamicModel, write_equation_tags); + writeLatexModelFile(basename, "dynamic", ExprNodeOutputType::latexDynamicModel, write_equation_tags); } void DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const { - writeLatexModelFile(basename + "_original", ExprNodeOutputType::latexDynamicModel, write_equation_tags); + writeLatexModelFile(basename, "original", ExprNodeOutputType::latexDynamicModel, write_equation_tags); } void diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc index 298fe77c..f765a897 100644 --- a/src/ModelEquationBlock.cc +++ b/src/ModelEquationBlock.cc @@ -132,10 +132,11 @@ SteadyStateModel::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat void SteadyStateModel::writeLatexSteadyStateFile(const string &basename) const { + boost::filesystem::create_directories(basename + "/latex"); + ofstream output, content_output; - string filename = basename + "_steady_state.tex"; - string content_basename = basename + "_steady_state_content"; - string content_filename = content_basename + ".tex"; + string filename = basename + "/latex/steady_state.tex"; + string content_filename = basename + "/latex/steady_state_content.tex"; output.open(filename, ios::out | ios::binary); if (!output.is_open()) @@ -172,7 +173,7 @@ SteadyStateModel::writeLatexSteadyStateFile(const string &basename) const static_model.writeLatexAuxVarRecursiveDefinitions(content_output); - output << "\\include{" << content_basename << "}" << endl + output << "\\include{steady_state_content.tex}" << endl << "\\end{document}" << endl; output.close(); diff --git a/src/ModelTree.cc b/src/ModelTree.cc index 8d4ccb22..cb5819bb 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1834,12 +1834,13 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename, } void -ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags) const +ModelTree::writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, const bool write_equation_tags) const { + boost::filesystem::create_directories(mod_basename + "/latex"); + ofstream output, content_output; - string filename = basename + ".tex"; - string content_basename = basename + "_content"; - string content_filename = content_basename + ".tex"; + string filename = mod_basename + "/latex/" + latex_basename + ".tex"; + string content_filename = mod_basename + "/latex/" + latex_basename + "_content" + ".tex"; output.open(filename, ios::out | ios::binary); if (!output.is_open()) { @@ -1906,7 +1907,7 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output content_output << endl << R"(\end{dmath})" << endl; } - output << R"(\include{)" << content_basename << "}" << endl + output << R"(\include{)" << latex_basename + "_content" << "}" << endl << R"(\end{document})" << endl; output.close(); diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 0dc0aa5a..04c26e95 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -191,7 +191,7 @@ protected: void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const; //! Writes LaTeX model file - void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags) const; + void writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, const bool write_equation_tags) const; //! Sparse matrix of double to store the values of the Jacobian /*! First index is equation number, second index is endogenous type specific ID */ diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 6babac0a..75340e6a 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -2380,7 +2380,7 @@ StaticModel::collect_block_first_order_derivatives() void StaticModel::writeLatexFile(const string &basename, bool write_equation_tags) const { - writeLatexModelFile(basename + "_static", ExprNodeOutputType::latexStaticModel, write_equation_tags); + writeLatexModelFile(basename, "static", ExprNodeOutputType::latexStaticModel, write_equation_tags); } void