Skip to content
Snippets Groups Projects
Commit 3afc6707 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

reporting: for easier figure reference, by default save report figures as:...

reporting: for easier figure reference, by default save report figures as: pg%d_sec%d_row%d_col%d.tex
parent 6d71e536
Branches
Tags
No related merge requests found
function o = write(o, fid)
%function o = write(o, fid)
function o = write(o, fid, pg, sec, row, col)
%function o = write(o, fid, pg, sec, row, col)
% Write a Graph object
%
% INPUTS
% o [graph] graph object
% fid [integer] file id
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [graph] graph object
......@@ -30,6 +34,6 @@ function o = write(o, fid)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(fid ~= -1);
o = writeGraphFile(o);
o = writeGraphFile(o, pg, sec, row, col);
fprintf(fid, '\\input{%s}', o.figname);
end
\ No newline at end of file
function o = writeGraphFile(o)
%function o = writeGraphFile(o)
function o = writeGraphFile(o, pg, sec, row, col)
%function o = writeGraphFile(o, pg, sec, row, col)
% Write the tikz file that contains the graph
%
% INPUTS
% o [graph] graph object
% o [graph] graph object
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [graph] graph object
......@@ -35,11 +39,7 @@ if ne < 1
end
if isempty(o.figname)
[junk, tn] = fileparts(tempname);
if strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
tn = strrep(tn, '_', '-');
end
o.figname = [o.figDirName '/' tn '.tex'];
o.figname = sprintf('%s/pg%d_sec%d_row%d_col%d.tex', o.figDirName, pg, sec, row, col);
end
[fid, msg] = fopen(o.figname, 'w');
......
function o = write(o, fid)
%function o = write(o, fid)
function o = write(o, fid, pg)
%function o = write(o, fid, pg)
% Write a Page object
%
% INPUTS
% o [page] page object
% fid [integer] file id
% pg [integer] this page number
%
% OUTPUTS
% o [page] page object
......@@ -48,7 +49,7 @@ end
nps = length(o.sections);
for i=1:nps
o.sections{i}.write(fid);
o.sections{i}.write(fid, pg, i);
end
if strcmpi(o.orientation, 'landscape')
......
......@@ -80,7 +80,7 @@ fprintf(fid, '\\centering\n');
nps = length(o.pages);
for i=1:nps
fprintf(1, 'Writing Page: %d\n', i);
o.pages{i}.write(fid);
o.pages{i}.write(fid, i);
end
fprintf(fid, '\\end{document}\n');
......
function o = write(o, fid)
%function o = write(o, fid)
function o = write(o, fid, pg, sec, row, col)
%function o = write(o, fid, pg, sec, row, col)
% Write a Report_Table object
%
% INPUTS
......
function o = write(o, fid)
%function o = write(o, fid)
function o = write(o, fid, pg, sec)
%function o = write(o, fid, pg, sec)
% Write Section object
%
% INPUTS
% o [section] section object
% fid [integer] file id
% pg [integer] this page number
% sec [integer] this section number
%
% OUTPUTS
% o [section] section object
......@@ -48,20 +50,24 @@ end
fprintf(fid, '}\n');
ne = numElements(o);
nlcounter = 0;
row = 1;
col = 1;
for i=1:ne
if isa(o.elements{i}, 'vspace')
assert(rem(nlcounter, o.cols) == 0, ['@section.write: must place ' ...
assert(col == o.cols, ['@section.write: must place ' ...
'vspace command after a linebreak in the table ' ...
'or series of charts']);
o.elements{i}.write(fid);
fprintf(fid, '\\\\\n');
else
o.elements{i}.write(fid);
nlcounter = nlcounter + 1;
if rem(nlcounter, o.cols)
o.elements{i}.write(fid, pg, sec, row, col);
if col ~= o.cols
fprintf(fid, ' & ');
col = col + 1;
else
fprintf(fid, '\\\\\n');
row = row + 1;
col = 1;
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment