reporting: add subtitle support for tables, ref #580

time-shift
Houtan Bastani 2014-02-17 10:59:23 +01:00
parent 052faa2f93
commit 522013f889
4 changed files with 26 additions and 15 deletions

View File

@ -10820,7 +10820,7 @@ Display a solid black line at @math{y = 0}. Default: @code{false}
@end table
@end defmethod
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleSize, vlineAfter, vlineAfterEndOfPeriod, showVlines
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleFormat, vlineAfter, vlineAfterEndOfPeriod, showVlines
Adds a @code{Table} to a @code{Section}.
@optionshead
@table @code
@ -10841,10 +10841,10 @@ The date range of the data to be displayed. Default: @code{all}
@xref{seriesToUse}.
@item title, @code{STRING}
Title for the table. Default: @code{none}
Same as @ref{title}, just for tables.
@item titleSize, @code{STRING}
@LaTeX{} string representing the size of the table title. Default: @code{large}
@item titleFormat, @code{STRING}
Same as @ref{titleFormat}, just for tables. Default: @code{\large}.
@item vlineAfter, @code{dates} | @code{CELL_ARRAY_DATES}
Show a vertical line after the specified date (or dates if a cell

View File

@ -33,8 +33,8 @@ o = struct;
o.series = {};
o.title = '';
o.titleSize = 'large';
o.title = {''};
o.titleFormat = {'\large'};
o.showHlines = false;
o.showVlines = false;
@ -79,7 +79,12 @@ if isa(o.vlineAfter, 'dates')
end
% Check options provided by user
assert(ischar(o.title), '@report_table.report_table: title must be a string');
if ischar(o.title)
o.title = {o.title};
end
if ischar(o.titleFormat)
o.titleFormat = {o.titleFormat};
end
assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false');
assert(islogical(o.showVlines), '@report_table.report_table: showVlines must be true or false');
assert(isint(o.precision), '@report_table.report_table: precision must be an int');
@ -97,10 +102,12 @@ if o.showVlines
end
assert(islogical(o.vlineAfterEndOfPeriod), ...
'@report_table.report_table: vlineAfterEndOfPeriod must be true or false');
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
'small', 'footnotesize', 'scriptsize', 'tiny'};
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...
['@report_table.report_table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
assert(iscellstr(o.title), ...
'@report_table.report_table: title must be a cell array of string(s)');
assert(iscellstr(o.titleFormat), ...
'@report_table.report_table: titleFormat must be a cell array of string(s)');
assert(length(o.title) == length(o.titleFormat), ...
'@report_table.report_table: title and titleFormat must have the same length');
% using o.seriesToUse, create series objects and put them in o.series
if ~isempty(o.data)

View File

@ -94,9 +94,11 @@ end
nrhc = length(rhscols);
ncols = ndates+nlhc+nrhc;
fprintf(fid, '@{}}%%\n');
if ~isempty(o.title)
fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ...
ncols, o.titleSize, o.title);
for i=1:length(o.title)
if ~isempty(o.title{i})
fprintf(fid, '\\multicolumn{%d}{c}{%s %s}\\\\\n', ...
ncols, o.titleFormat{i}, o.title{i});
end
end
fprintf(fid, '\\toprule%%\n');

View File

@ -42,7 +42,9 @@ rep = rep.addSection();
rep = rep.addVspace();
% Table 1
rep = rep.addTable('title', 'Real GDP Growth', 'range', larange, ...
rep = rep.addTable('title', {'Real GDP Growth','subtitle 1', 'subtitle 2'}, ...
'titleFormat', {'\large\bfseries','\small\bfseries','\tiny'}, ...
'range', larange, ...
'vlineAfter', dates('2011y'));
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_', larange);
rep = rep.addVspace('number', 2);