Commit b7969980 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

reporting: @page: allow for multiple titles, title_format, first args can be...

reporting: @page: allow for multiple titles, title_format, first args can be provided as strings or cellstr, multiple args as cellstr
parent ea56c41b
......@@ -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');
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment