diff --git a/matlab/reporting/@page/page.m b/matlab/reporting/@page/page.m index 20af0b8ff84b7c4ef4cb23df62d46230a4adcf9c..430a0b113dd37f12b6ea1a88519d3f2b58771359 100644 --- a/matlab/reporting/@page/page.m +++ b/matlab/reporting/@page/page.m @@ -31,9 +31,10 @@ function o = page(varargin) o = struct; o.paper = ''; -o.title = ''; +o.title = {}; +o.title_format = {}; o.orientation = ''; -o.footnote = ''; +o.footnote = {}; o.sections = sections(); if nargin == 1 @@ -61,7 +62,18 @@ elseif nargin > 1 end % Check options provided by user -assert(ischar(o.title), '@page.page: title must be a string'); +if ischar(o.title) + o.title = {o.title} +end +if ischar(o.title_format) + o.title_format = {o.title_format} +end +assert(iscellstr(o.title), ... + '@page.page: title must be a cell array of strings'); +assert(iscellstr(o.title_format), ... + '@page.page: title_format must be a cell array of strings'); +assert(length(o.title)==length(o.title_format), ... + '@page.page: title and title_format must be of the same length'); valid_paper = {'a4', 'letter'}; assert(any(strcmp(o.paper, valid_paper)), ... @@ -71,13 +83,11 @@ valid_orientation = {'portrait', 'landscape'}; assert(any(strcmp(o.orientation, valid_orientation)), ... ['@page.page: orientation must be one of ' strjoin(valid_orientation, ' ')]); -msg = ['@page.page: footnote must be a cell array of string(s)']; -if ~isempty(o.footnote) - assert(iscell(o.footnote), msg); - for i=1:length(o.footnote) - assert(ischar(o.footnote{i}), msg); - end +if ischar(o.footnote) + o.footnote = {o.footnote} end +assert(iscellstr(o.footnote), ... + '@page.page: footnote must be a cell array of string(s)'); % Create page object o = class(o, 'page'); diff --git a/matlab/reporting/@page/write.m b/matlab/reporting/@page/write.m index 9afb4ad30b4c8504bf9bc0b175d6cf4d368004de..f04e7e4b1fc21f755f429a16bd1f751d6f5568f5 100644 --- a/matlab/reporting/@page/write.m +++ b/matlab/reporting/@page/write.m @@ -31,18 +31,18 @@ function o = write(o, fid) assert(fid ~= -1); fprintf(fid, '\n%% Page Object\n'); -if ~isempty(o.title) - fprintf(fid, '\\centerline{\\large\\textbf{%s}}\n', o.title); +if strcmpi(o.orientation, 'landscape') + fprintf(fid, '\\begin{landscape}\n') end -if ~isempty(o.footnote) - for i=1:length(o.footnote) - fprintf(fid, '\\blfootnote{\\tiny %d. %s}', i, o.footnote{i}); - end +for i=1:length(o.footnote) + fprintf(fid, '\\blfootnote{\\tiny %d. %s}', i, o.footnote{i}); end +fprintf(fid,'\n'); -if strcmpi(o.orientation, 'landscape') - fprintf(fid, '\\begin{landscape}\n') +fprintf(fid, '\\begin{tabular}[t]{@{\\hspace*{-3pt}}c@{}}\n'); +for i=1:length(o.title) + fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.title_format{i}, o.title{i}); end o.sections.write(fid); @@ -50,6 +50,7 @@ o.sections.write(fid); if strcmpi(o.orientation, 'landscape') fprintf(fid, '\\end{landscape}\n'); end +fprintf(fid, '\\end{tabular}\n'); fprintf(fid, '\\clearpage\n'); fprintf(fid, '%% End Page Object\n\n'); end \ No newline at end of file