diff --git a/matlab/reports/@report/compile.m b/matlab/reports/@report/compile.m new file mode 100644 index 0000000000000000000000000000000000000000..14990e912d08d8ae964101efb9a0bfec57d83c2d --- /dev/null +++ b/matlab/reports/@report/compile.m @@ -0,0 +1,63 @@ +function o = compile(o) +%function o = compile(o) +% Compile Report Object +% +% INPUTS +% o [report] report object +% +% OUTPUTS +% o [report] report object +% +% 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/>. + +if ~exist(o.filename, 'file') + o.write(); +end + +compiler = o.compiler; +if isempty(compiler) + if strcmp(computer, 'MACI') || strcmp(computer, 'MACI64') + % Add most likely places for pdflatex to + % exist outside of default $PATH + [status, compiler] = ... + system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ... + 'which pdflatex'], '-echo'); + elseif strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64') + % need to fill in for Windows + else % gnu/linux + [status, compiler] = system('which pdflatex', '-echo'); + end + assert(status == 0, ... + '@report.compile: Could not find a tex compiler on your system'); + compiler = strtrim(compiler); + o.compiler = compiler; +end +[status output] = system([compiler ' ./' o.filename], '-echo'); +[junk, rfn, junk] = fileparts(o.filename); + +if status ~= 0 + error(['@report.compile: There was an error in compiling ' rfn '.pdf.' ... + ' ' compiler ' returned the error code: ' num2str(status)]); +end +fprintf(1, '\n\nDone.\n') +disp('Your compiled report is located here:'); +disp([' ' pwd filesep rfn '.pdf']); +end \ No newline at end of file diff --git a/matlab/reports/@report/report.m b/matlab/reports/@report/report.m index d55984b26e96c8fbdd8278b8ec27b97afb63147c..2f440ebbadb9d64ca65771740c9da7beff1a1044 100644 --- a/matlab/reports/@report/report.m +++ b/matlab/reports/@report/report.m @@ -41,6 +41,7 @@ o.pages = pages(); o.filename = 'report.tex'; o.config = ''; o.showdate = true; +o.compiler = ''; if nargin == 1 assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ... @@ -71,6 +72,7 @@ end assert(ischar(o.title), '@report.report: title must be a string'); assert(ischar(o.filename), '@report.report: filename must be a string'); assert(ischar(o.config), '@report.report: config file must be a string'); +assert(ischar(o.compiler), '@report.report: compiler file must be a string'); assert(islogical(o.showdate), '@report.report: showdate must be either true or false'); assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');