diff --git a/matlab/reporting/@elements/addGraph.m b/matlab/reporting/@elements/addGraph.m index 5149e3f1ecd5a5fae73e50a289ddaeb04c0082dc..ace48fc87c42739a78338e4fb17b161124620e81 100644 --- a/matlab/reporting/@elements/addGraph.m +++ b/matlab/reporting/@elements/addGraph.m @@ -18,10 +18,5 @@ function e = addGraph(e, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(nargin >= 1 && nargin <= 3) -if nargin == 1 - e.objArray = e.objArray.addObj(graph()); -else - e.objArray = e.objArray.addObj(varargin{:}); -end +e.objArray = e.objArray.addObj(graph(varargin{:})); end \ No newline at end of file diff --git a/matlab/reporting/@elements/addTable.m b/matlab/reporting/@elements/addTable.m index 6fe074dee9348c16e2591d0a73954e92df926580..afcc8e05239c6ad690f37f443e110514032d646a 100644 --- a/matlab/reporting/@elements/addTable.m +++ b/matlab/reporting/@elements/addTable.m @@ -18,10 +18,5 @@ function e = addTable(e, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(nargin >= 1 && nargin <= 3) -if nargin == 1 - e.objArray = e.objArray.addObj(table()); -else - e.objArray = e.objArray.addObj(varargin{:}); -end +e.objArray = e.objArray.addObj(table(varargin{:})); end \ No newline at end of file diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m new file mode 100644 index 0000000000000000000000000000000000000000..b696a305e2af5f3e8830740fec081623403bb6a9 --- /dev/null +++ b/matlab/reporting/@graph/createGraph.m @@ -0,0 +1,107 @@ +function o = createGraph(o) +%function o = createGraph(o) +% Create the graph +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(~isempty(o.data)); +assert(isa(o.data, 'dynSeries')) ; + +if ~isempty(o.figname) + warning('Will overwrite %s with new graph\n', o.figname); +end + +%o = readConfig(o); + +h = figure('visible','off'); +hold on; +box on; +%set(0, 'CurrentFigure',h); +%set(h, 'PaperPositionMode', 'auto'); +%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]); + +if strcmpi(o.seriestoplot, 'all') + data = o.data.data; +else + data = o.data{o.seriestoplot{:}}.data; +end + +x=[1:1:o.data.nobs]; +xlabels=getDatesCellStringArray(o.data.time); + +plot(x, data); + +if ~isempty(o.shade) + x1 = strmatch(lower(o.shade{1}), xlabels, 'exact'); + x2 = strmatch(lower(o.shade{2}), xlabels, 'exact'); + yrange = get(gca, 'YLim'); + + % From ShadePlotForEmpahsis (Matlab Exchange) + % use patch bc area doesn't work with matlab2tikz + patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], [yrange fliplr(yrange)], ... + 'b', 'FaceAlpha', .2); +end + +set(gca,'XTick', x); +set(gca,'XTickLabel', xlabels); + +if o.legend + if strcmpi(o.seriestoplot, 'all') + lh = legend(o.data.name); + else + lh = legend(o.seriestoplot{:}); + end + set(lh, 'orientation', o.legend_orientation); + set(lh, 'Location', o.legend_location); + set(lh, 'FontSize', o.legend_font_size); + legend('boxoff'); +end + +if ~isempty(o.xlabel) + xlabel(['$\textbf{\footnotesize ' o.xlabel '}$'],'Interpreter','LaTex'); +end + +if ~isempty(o.ylabel) + ylabel(['$\textbf{\footnotesize ' o.ylabel '}$'],'Interpreter','LaTex'); +end + +if ~isempty(o.title) + title(['$\textbf{\large ' o.title '}$'],'Interpreter','LaTex'); +end +drawnow; + +o.figname = ['figure-' num2str(cputime) '.tex']; +matlab2tikz('filename', o.figname, ... + 'showInfo', false, ... + 'showWarnings', false, ... + 'checkForUpdates', false); + +box off; +hold off; +close(h); +clear h; +end diff --git a/matlab/reporting/@graph/display.m b/matlab/reporting/@graph/display.m index f9f9d82fcfeae1de764e58cc1e6dde65b15437db..71c2b2ea257f3a8b942609014cb25dcfd8738ea1 100644 --- a/matlab/reporting/@graph/display.m +++ b/matlab/reporting/@graph/display.m @@ -30,9 +30,19 @@ function display(o) name = 'report.page.section.graph'; disp(' '); -disp([name '.caption = ']); +disp([name '.title = ']); disp(' '); -disp([' ''' o.caption '''']); +disp([' ''' o.title '''']); + +disp(' '); +disp([name '.xlabel = ']); +disp(' '); +disp([' ''' o.xlabel '''']); + +disp(' '); +disp([name '.ylabel = ']); +disp(' '); +disp([' ''' o.ylabel '''']); disp(' '); disp([name '.footnote = ']); @@ -40,7 +50,32 @@ disp(' '); disp([' ''' o.footnote '''']); disp(' '); -disp([name '.filename = ']); +disp([name '.figname = ']); +disp(' '); +disp([' ''' o.figname '''']); + +disp(' '); +disp([name '.data = ']); +disp(' '); +display(o.data); + +disp(' '); +disp([name '.seriestoplot = ']); +disp(' '); +disp(o.seriestoplot); + +disp(' '); +disp([name '.config = ']); +disp(' '); +disp([' ''' o.config '''']); + +disp(' '); +disp([name '.legend = ']); +disp(' '); +disp(o.legend); + +disp(' '); +disp([name '.shade = ']); disp(' '); -disp([' ''' o.filename '''']); +disp(o.shade); end \ No newline at end of file diff --git a/matlab/reporting/@graph/graph.m b/matlab/reporting/@graph/graph.m index 48ed3501a5f9eec863c2509767292b9c133a0acc..2d7d87c2cebc404009ff83bbdfcde4e7b887dcdf 100644 --- a/matlab/reporting/@graph/graph.m +++ b/matlab/reporting/@graph/graph.m @@ -30,11 +30,24 @@ function o = graph(varargin) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. o = struct; -o.caption = ''; + +o.config = ''; + +o.title = ''; +o.ylabel = ''; +o.xlabel = ''; +o.zlabel = ''; o.footnote = ''; -o.filename = ''; + +o.figname = ''; o.data = ''; -o.config = ''; +o.seriestoplot = 'all'; +o.shade = ''; %{1959q1:1964q4} + +o.legend = false; +o.legend_location = 'SouthEast'; +o.legend_orientation = 'horizontal'; +o.legend_font_size = 8; if nargin == 1 assert(isa(varargin{1}, 'graph'),['With one arg to Graph constructor, ' ... diff --git a/matlab/reporting/@graph/write.m b/matlab/reporting/@graph/write.m index 4ad52ff8cf7837a0afd4707f13e450e4bf8d282d..aecf8ab08d39e307b51c0ed94e828f02e617c770 100644 --- a/matlab/reporting/@graph/write.m +++ b/matlab/reporting/@graph/write.m @@ -1,12 +1,12 @@ -function write(o, fid, texIndent) -%function write(o, fid) -% Write a Page object +function o = write(o, fid) +%function o = write(o, fid) +% Write a Graph object % % INPUTS -% none +% fid - int, file id % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -28,13 +28,9 @@ function write(o, fid, texIndent) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(fid > 0); -assert(isnumeric(texIndent)); - -fprintf(fid, '%d\% Page Object\n', texIndent); -fprintf(fid, '%d\newpage\n', texIndent); - -o.sections.write(fid, texIndent+2); - -fprintf(fid, '%d\% End Page Object\n', texIndent); +assert(fid ~= -1); +if isempty(o.figname) + o = createGraph(o); +end +fprintf(fid, '\\input{%s}', o.figname); end \ No newline at end of file diff --git a/matlab/reporting/@page/addSection.m b/matlab/reporting/@page/addSection.m index c9855ae3a62648e5dfdc8a6a9b3849b514b0faec..b24c16b89e3e9c574eca8fd8c27226f23f7f1e4f 100644 --- a/matlab/reporting/@page/addSection.m +++ b/matlab/reporting/@page/addSection.m @@ -30,10 +30,5 @@ function p = addSection(p, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(isa(p, 'page'), 'First argument must be a page object'); -if nargin == 1 - p.sections = p.sections.addSection(); -elseif nargin == 2 || nargin == 3 - p.sections = p.sections.addSection(varargin{:}); -end +p.sections = p.sections.addSection(varargin{:}); end diff --git a/matlab/reporting/@page/page.m b/matlab/reporting/@page/page.m index f0988d5717c9e18a86181ce42597dcad0bf413ac..f7f1c2c453f259abaefde196e63041ebee55f226 100644 --- a/matlab/reporting/@page/page.m +++ b/matlab/reporting/@page/page.m @@ -30,12 +30,13 @@ function o = page(varargin) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. o = struct; -o.caption = ''; -o.orientation = 'portrait'; +o.paper = ''; +o.title = ''; +o.orientation = ''; o.sections = sections(); if nargin == 1 - assert(isa(varargin{1}, 'page'),['With one arg to Page constructor, ' ... + assert(isa(varargin{1}, 'page'), ['With one arg to Page constructor, ' ... 'you must pass a page object']); o = varargin{1}; return; diff --git a/matlab/reporting/@page/subsref.m b/matlab/reporting/@page/subsref.m index 33524ac793dc379271d966753c93a6b09e413072..7b3826bb94208d97283882811f845e46cee36672 100644 --- a/matlab/reporting/@page/subsref.m +++ b/matlab/reporting/@page/subsref.m @@ -23,13 +23,6 @@ switch S(1).type switch S(1).subs case fieldnames(A) A = A.(S(1).subs); - case {'write'} - if areParensNext(S) - write(A, S(2).subs{:}) - S = shiftS(S); - else - assert(false); - end case methods(A) if areParensNext(S) A = feval(S(1).subs, A, S(2).subs{:}); diff --git a/matlab/reporting/@page/write.m b/matlab/reporting/@page/write.m index 515a8b81982ca39a40be91f7216474cf5e964f35..4944b3d5109ced773b44842d104ee52e5ac6e4f4 100644 --- a/matlab/reporting/@page/write.m +++ b/matlab/reporting/@page/write.m @@ -1,13 +1,12 @@ -function write(o, fid, indent) -%function write(o, fid, indent) +function o = write(o, fid) +%function o = write(o, fid) % Write a Page object % % INPUTS % fid - int, file id -% indent - char, number of spaces to indent tex code % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -31,14 +30,19 @@ function write(o, fid, indent) assert(fid ~= -1); -fprintf(fid, '\n%s%% Page Object\n', indent); +fprintf(fid, '\n%% Page Object\n'); +if ~isempty(o.title) + fprintf(fid, '\\centerline{{\\Large %s}}\n', o.title); +end if strcmpi(o.orientation, 'landscape') - fprintf(fid, '%s\\begin{landscape}\n', indent); + fprintf(fid, '\\begin{landscape}\n') end -o.sections.write(fid, addIndentation(indent)); + +o.sections.write(fid); + if strcmpi(o.orientation, 'landscape') - fprintf(fid, '%s\\end{landscape}\n', indent); + fprintf(fid, '\\end{landscape}\n'); end -fprintf(fid, '%s\\clearpage\n', indent); -fprintf(fid, '%s%% End Page Object\n\n', indent); +fprintf(fid, '\\clearpage\n'); +fprintf(fid, '%% End Page Object\n\n'); end \ No newline at end of file diff --git a/matlab/reporting/@pages/addPage.m b/matlab/reporting/@pages/addPage.m index 072f04f575d5640d47c29688f975d80d2825e8cb..174d39b23de987512d171e60a705a2a09dbb0c33 100644 --- a/matlab/reporting/@pages/addPage.m +++ b/matlab/reporting/@pages/addPage.m @@ -18,10 +18,11 @@ function ps = addPage(ps, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(nargin >= 1 && nargin <= 3) -if nargin == 1 - ps.objArray = ps.objArray.addObj(page()); -else - ps.objArray = ps.objArray.addObj(varargin{:}); -end +ps.objArray = ps.objArray.addObj(page(varargin{:})); +%assert(nargin >= 1 && nargin <= 3) +%if nargin == 1 +% ps.objArray = ps.objArray.addObj(page()); +%else +% ps.objArray = ps.objArray.addObj(varargin{:}); +%end end \ No newline at end of file diff --git a/matlab/reporting/@pages/subsref.m b/matlab/reporting/@pages/subsref.m index 1e5db0297eba54af4f9d9809019047016c2c8a91..8d78e5c2632954d8fa8ab4c28559cebd44e71526 100644 --- a/matlab/reporting/@pages/subsref.m +++ b/matlab/reporting/@pages/subsref.m @@ -23,13 +23,6 @@ switch S(1).type switch S(1).subs case fieldnames(A) A = A.(S(1).subs); - case {'write'} - if areParensNext(S) - write(A, S(2).subs{:}) - S = shiftS(S); - else - assert(false); - end case methods(A) if areParensNext(S) A = feval(S(1).subs, A, S(2).subs{:}); diff --git a/matlab/reporting/@pages/write.m b/matlab/reporting/@pages/write.m index 8bb89e3682e096e6f11e5c5c1c2aade9b8fb8499..0c6efe5fb699391ee1cfedfa9c97c321afff2df4 100644 --- a/matlab/reporting/@pages/write.m +++ b/matlab/reporting/@pages/write.m @@ -1,13 +1,12 @@ -function write(o, fid, indent) -%function write(o, fid, indent) +function o = write(o, fid) +%function o = write(o, fid) % Write Pages object % % INPUTS % fid - int, file id -% indent - char, number of spaces to indent tex code % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -30,10 +29,10 @@ function write(o, fid, indent) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. assert(fid ~= -1); -fprintf(fid, '\n%s%% Pages Object\n', indent); +fprintf(fid, '\n%% Pages Object\n'); nps = numPages(o); for i=1:nps - o.objArray(i).write(fid, addIndentation(indent)); + o.objArray(i).write(fid); end -fprintf(fid, '%s%% End Pages Object\n\n', indent); +fprintf(fid, '%% End Pages Object\n\n'); end \ No newline at end of file diff --git a/matlab/reporting/@report/addPage.m b/matlab/reporting/@report/addPage.m index 8299f973d68b2b05069acfc4fddccab57efa8e9f..f5f2c2468f93f0a8b1383283ff891dfac9b9bd2b 100644 --- a/matlab/reporting/@report/addPage.m +++ b/matlab/reporting/@report/addPage.m @@ -1,5 +1,5 @@ -function r = addPage(r, varargin) -%function r = addPage(r, varargin) +function o = addPage(o, varargin) +%function o = addPage(o, varargin) % Add a page to the Cell Array of pages in the report % % INPUTS @@ -30,21 +30,22 @@ function r = addPage(r, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ... - 'to addPage']); -assert(isa(r, 'report'), 'First argument must be a report object'); -if nargin > 1 - assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ... - 'Page']); - if nargin > 2 - assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ... - 'an index']); - end -end +%assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ... +% 'to addPage']); +%assert(isa(r, 'report'), 'First argument must be a report object'); +%if nargin > 1 +% assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ... +% 'Page']); +% if nargin > 2 +% assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ... +% 'an index']); +% end +%end if nargin == 1 - r.pages = r.pages.addPage(); -elseif nargin == 2 || nargin == 3 - r.pages = r.pages.addPage(varargin{:}); + o.pages = o.pages.addPage('orientation', o.orientation, 'paper', o.paper); +else + o.pages = o.pages.addPage('orientation', o.orientation, 'paper', ... + o.paper, varargin{:}); end end diff --git a/matlab/reporting/@report/report.m b/matlab/reporting/@report/report.m index e4e193abd4f9f21fa28220ff01017ea9ad93f9fd..a045c5c88003d29d59c7dc66b107382e094d023f 100644 --- a/matlab/reporting/@report/report.m +++ b/matlab/reporting/@report/report.m @@ -34,6 +34,7 @@ o = struct; o.title = ''; o.orientation = 'portrait'; o.paper = 'a4'; +o.margin = '2cm'; o.pages = pages(); o.filename = 'report.tex'; o.config = ''; diff --git a/matlab/reporting/@report/subsref.m b/matlab/reporting/@report/subsref.m index 25a3001a35ba2fb4a4b6ed802a2d1997fe56cc95..9559393fe62e22803d88c46c1580342f465a08f6 100644 --- a/matlab/reporting/@report/subsref.m +++ b/matlab/reporting/@report/subsref.m @@ -23,13 +23,6 @@ switch S(1).type switch S(1).subs case fieldnames(A) A = A.(S(1).subs); - case {'write'} - if areParensNext(S) - write(A, S(2).subs{:}) - S = shiftS(S); - else - write(A); - end case methods(A) if areParensNext(S) A = feval(S(1).subs, A, S(2).subs{:}); diff --git a/matlab/reporting/@report/write.m b/matlab/reporting/@report/write.m index 124edb96c717d887b8fee36fa6ad2f4a149cad4e..6b686c662e2b0ef1554bd2491d750622523fe637 100644 --- a/matlab/reporting/@report/write.m +++ b/matlab/reporting/@report/write.m @@ -1,12 +1,12 @@ -function write(o) -%function write(o) +function o = write(o) +%function o = write(o) % Write Report object % % INPUTS -% none +% o - Report Object % % OUTPUTS -% none +% o - Report Object % % SPECIAL REQUIREMENTS % none @@ -36,16 +36,18 @@ end fprintf(fid, '%% Report Object\n'); fprintf(fid, '\\documentclass[11pt]{article}\n'); -fprintf(fid, '\\usepackage[%spaper,margin=2.5cm', o.paper); +fprintf(fid, '\\usepackage[%spaper,margin=%s', o.paper, o.margin); if strcmpi(o.orientation, 'landscape') fprintf(fid, ',landscape'); end fprintf(fid, ']{geometry}\n'); fprintf(fid, '\\usepackage{graphicx}\n'); -fprintf(fid, '\\usepackage{pdflscape}\n') +fprintf(fid, '\\usepackage{pdflscape}\n'); +fprintf(fid, '\\usepackage{pgf}\n'); +fprintf(fid, '\\usepackage{pgfplots}\n'); fprintf(fid, '\\begin{document}\n'); -o.pages.write(fid, addIndentation('')); +o.pages.write(fid); fprintf(fid, '\\end{document}\n'); fprintf(fid, '%% End Report Object\n'); diff --git a/matlab/reporting/@section/addGraph.m b/matlab/reporting/@section/addGraph.m index dd41fa438780c6c412a1862fe0f300c6fa8fa82e..28e6e80b9b29afc33c5a56659c4a1924223fba9f 100644 --- a/matlab/reporting/@section/addGraph.m +++ b/matlab/reporting/@section/addGraph.m @@ -30,10 +30,5 @@ function o = addGraph(o, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(isa(o, 'section'), 'First argument must be a section object'); -if nargin == 1 - o.elements = o.elements.addGraph(); -elseif nargin == 2 || nargin == 3 - o.elements = o.elements.addGraph(varargin{:}); -end +o.elements = o.elements.addGraph(varargin{:}); end diff --git a/matlab/reporting/@section/addTable.m b/matlab/reporting/@section/addTable.m index d9601828999cdfbb09c6a42a33df2fe5d93cc880..7e9390c96cf5a132da2282f1e457f8efa7ddd737 100644 --- a/matlab/reporting/@section/addTable.m +++ b/matlab/reporting/@section/addTable.m @@ -30,10 +30,5 @@ function o = addTable(o, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(isa(o, 'section'), 'First argument must be a section object'); -if nargin == 1 - o.elements = o.elements.addTable(); -elseif nargin == 2 || nargin == 3 - o.elements = o.elements.addTable(varargin{:}); -end +o.elements = o.elements.addTable(varargin{:}); end diff --git a/matlab/reporting/@section/display.m b/matlab/reporting/@section/display.m index 4ca24a0184ec1c3d930c39e308124077be8f91d3..67d9c5cc2291b85d60a12fbd6729d764e3589ba2 100644 --- a/matlab/reporting/@section/display.m +++ b/matlab/reporting/@section/display.m @@ -34,9 +34,13 @@ disp([name '.align = ']); disp(' '); disp([' ''' o.align '''']); +disp(' '); +disp([name '.cols = ']); +disp(' '); +disp(o.cols); + disp(' '); disp([name '.elements = ']); disp(' '); disp(o.elements.getElements()); - end \ No newline at end of file diff --git a/matlab/reporting/@section/section.m b/matlab/reporting/@section/section.m index 94d1fc0ad97a8e2df42cc271db11f5b799741a87..e2260f47b25cd3b24cc828c83285c4bcf936d69c 100644 --- a/matlab/reporting/@section/section.m +++ b/matlab/reporting/@section/section.m @@ -23,10 +23,8 @@ function o = section(varargin) o = struct; o.align = 't'; o.elements = elements(); -o.rows = 1; o.cols = 1; - if nargin == 1 assert(isa(varargin{1}, 'section'),['With one arg to Section constructor, ' ... 'you must pass a section object']); @@ -55,4 +53,3 @@ end % Create section object o = class(o, 'section'); end - diff --git a/matlab/reporting/@section/subsref.m b/matlab/reporting/@section/subsref.m index cf3c18010db572e7708ea662b3d50b77a1704b53..eeb041c5301d038b9795f89498bd056d5e55408e 100644 --- a/matlab/reporting/@section/subsref.m +++ b/matlab/reporting/@section/subsref.m @@ -23,13 +23,6 @@ switch S(1).type switch S(1).subs case fieldnames(A) A = A.(S(1).subs); - case {'write'} - if areParensNext(S) - write(A, S(2).subs{:}) - S = shiftS(S); - else - assert(false); - end case methods(A) if areParensNext(S) A = feval(S(1).subs, A, S(2).subs{:}); @@ -41,7 +34,7 @@ switch S(1).type error(['Section Class: unknown field or method: ' S(1).subs]); end case '()' - A = getElements(A, S(1).subs{:}); + A = A.elements.getElements(S(1).subs{:}); case '{}' error(['Section Class: ' S(1).type ' indexing not supported.']); otherwise diff --git a/matlab/reporting/@section/write.m b/matlab/reporting/@section/write.m index aa81110ab1859721f504d196a5dc6495866d4d5a..85e451fdf62f414d34be3c2299c3295d3d2b111e 100644 --- a/matlab/reporting/@section/write.m +++ b/matlab/reporting/@section/write.m @@ -1,13 +1,12 @@ -function write(o, fid, indent) -%function write(o, fid, indent) +function o = write(o, fid) +%function o = write(o, fid) % Write Section object % % INPUTS % fid - int, file id -% indent - char, number of spaces to indent tex code % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -31,14 +30,30 @@ function write(o, fid, indent) assert(fid ~= -1); -fprintf(fid, '\n%s%% Section Object\n', indent); -fprintf(fid, '%s\\noindent\\begin{minipage}[%s]{0.32\\hsize}\n', indent, o.align); +fprintf(fid, '%% Section Object\n'); +fprintf(fid, '\\begin{table}[%shtpb]\n', o.align); +fprintf(fid, '\\resizebox{\\textwidth}{!}{\n'); +fprintf(fid, '\\begin{tabular}{'); +for i=1:o.cols + fprintf(fid, 'c'); +end +fprintf(fid, '}\n'); + +% Calculate scaling factor +%sf = round(100/o.cols)/100-.01; ne = numElements(o); for i=1:ne - o.elements(i).write(fid, addIndentation(indent)); + o.elements(i).write(fid); + if rem(i, o.cols) + fprintf(fid, ' & '); + else + fprintf(fid, '\\\\\n'); + end end -fprintf(fid, '%s\\end{minipage}\n', indent); -fprintf(fid, '%s%% End Section Object\n\n', indent); +fprintf(fid, '\\end{tabular}\n'); +fprintf(fid, '}\n'); +fprintf(fid, '\\end{table}\n'); +fprintf(fid, '%% End Section Object\n\n'); end \ No newline at end of file diff --git a/matlab/reporting/@sections/addSection.m b/matlab/reporting/@sections/addSection.m index af412a412a1f17d2c0cc8be5397869f9bc711153..08bf94813f5e04e37c64c682dfe2762d178894b9 100644 --- a/matlab/reporting/@sections/addSection.m +++ b/matlab/reporting/@sections/addSection.m @@ -18,15 +18,5 @@ function ss = addSection(ss, varargin) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -assert(nargin >= 1 && nargin <= 3) -if nargin > 1 - assert(isa(varargin{1},'section'), ['Optional 2nd arg to addSection ' ... - 'must be a Section']); -end - -if nargin == 1 - ss.objArray = ss.objArray.addObj(section()); -else - ss.objArray = ss.objArray.addObj(varargin{:}); -end +ss.objArray = ss.objArray.addObj(section(varargin{:})); end \ No newline at end of file diff --git a/matlab/reporting/@sections/subsref.m b/matlab/reporting/@sections/subsref.m index d777cd0206ca30ecb498bcd7bff8199f9e02857b..89e2948f8098fdb651795efe75e4fd6526514821 100644 --- a/matlab/reporting/@sections/subsref.m +++ b/matlab/reporting/@sections/subsref.m @@ -23,13 +23,6 @@ switch S(1).type switch S(1).subs case fieldnames(A) A = A.(S(1).subs); - case {'write'} - if areParensNext(S) - write(A, S(2).subs{:}) - S = shiftS(S); - else - assert(false); - end case methods(A) if areParensNext(S) A = feval(S(1).subs, A, S(2).subs{:}); diff --git a/matlab/reporting/@sections/write.m b/matlab/reporting/@sections/write.m index 3370edd6865a737db7f257a7af0e80d2ada45962..937bd3c17875570eefacda5646b8d4e4118cc437 100644 --- a/matlab/reporting/@sections/write.m +++ b/matlab/reporting/@sections/write.m @@ -1,13 +1,12 @@ -function write(o, fid, indent) -%function write(o, fid, indent) +function o = write(o, fid) +%function o = write(o, fid) % Write Sections object % % INPUTS % fid - int, file id -% indent - char, number of spaces to indent tex code % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -30,10 +29,10 @@ function write(o, fid, indent) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. assert(fid ~= -1); -fprintf(fid, '\n%s%% Sections Object\n', indent); +fprintf(fid, '\n%% Sections Object\n'); nps = numSections(o); for i=1:nps - o.objArray(i).write(fid, indent); + o.objArray(i).write(fid); end -fprintf(fid, '%s%% End Sections Object\n\n', indent); +fprintf(fid, '%% End Sections Object\n\n'); end \ No newline at end of file diff --git a/matlab/reporting/@table/write.m b/matlab/reporting/@table/write.m index 4ad52ff8cf7837a0afd4707f13e450e4bf8d282d..129ae38a1ac13bfe0e5ceef37afaf0089dc708a2 100644 --- a/matlab/reporting/@table/write.m +++ b/matlab/reporting/@table/write.m @@ -1,12 +1,12 @@ -function write(o, fid, texIndent) -%function write(o, fid) -% Write a Page object +function o = write(o, fid) +%function o = write(o, fid) +% Write a Table object % % INPUTS -% none +% fid - int, file id % % OUTPUTS -% none +% o - this % % SPECIAL REQUIREMENTS % none @@ -31,10 +31,7 @@ function write(o, fid, texIndent) assert(fid > 0); assert(isnumeric(texIndent)); -fprintf(fid, '%d\% Page Object\n', texIndent); -fprintf(fid, '%d\newpage\n', texIndent); - -o.sections.write(fid, texIndent+2); +fprintf(fid, '%% Page Object\n'); -fprintf(fid, '%d\% End Page Object\n', texIndent); +fprintf(fid, '%% End Page Object\n'); end \ No newline at end of file diff --git a/matlab/reporting/addIndentation.m b/matlab/reporting/addIndentation.m deleted file mode 100644 index 4bbea49b76d5cf115f6d7fbd54c56fb0fe75da28..0000000000000000000000000000000000000000 --- a/matlab/reporting/addIndentation.m +++ /dev/null @@ -1,31 +0,0 @@ -function spaces=addIndentation(spaces) -% Return new level of indentation for latex output -% -% INPUTS -% spaces - char, current level of indentation -% -% OUTPUTS -% spaces - char, new level of indentation -% -% SPECIAL REQUIREMENTS -% none - -% Copyright (C) 2013 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see <http://www.gnu.org/licenses/>. - -spaces = [spaces ' ']; -end \ No newline at end of file