From f2fd7524d73b240e5c1764f33b37ed92c03484fe Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Wed, 6 Nov 2019 13:01:10 -0500 Subject: [PATCH] allow for the removal of headers and footers from a given page. closes #15 --- src/@page/page.m | 21 ++++++++++++--------- src/@page/write.m | 3 +++ test/createReport.m | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/@page/page.m b/src/@page/page.m index 25be2d9..320c02b 100644 --- a/src/@page/page.m +++ b/src/@page/page.m @@ -24,15 +24,16 @@ classdef page < handle sections = {} end properties (SetAccess = private) - paper = '' % Paper size. Default: `a4'. - title = {''} % With one entry (a STRING), the title of the page. With more than one entry (a CELL_ARRAY_STRINGS), the title and subtitle(s) of the page. Values passed must be valid LATEX code (e.g., % must be \%). Default: none. - titleFormat = '' % A string representing the valid LATEX markup to use on title. The number of cell array entries must be equal to that of the title option if you do not want to use the default value for the title (and subtitles). Default: \large\bfseries. - titleTruncate = '' % Useful when automatically generating page titles that may become too long, titleTruncate can be used to truncate a title (and subsequent subtitles) when they pass the specified number of characters. Default: .off. - orientation = '' % Paper orientation: Default: `portrait'. - footnote = {} % A footnote to be included at the bottom of this page. Default: none. - pageDirName = 'tmpRepDir' % The name of the folder in which to store this page. Only used when the latex command is passed. Default: tmpRepDir. - latex = '' % The valid LATEX code to be used for this page. Alows the user to create a page to be included in the report by passing LATEX code directly. Default: empty. - setPageNumber = '' % If true, reset the page number counter. Default: false. + paper = '' % Paper size. Default: `a4'. + title = {''} % With one entry (a STRING), the title of the page. With more than one entry (a CELL_ARRAY_STRINGS), the title and subtitle(s) of the page. Values passed must be valid LATEX code (e.g., % must be \%). Default: none. + titleFormat = '' % A string representing the valid LATEX markup to use on title. The number of cell array entries must be equal to that of the title option if you do not want to use the default value for the title (and subtitles). Default: \large\bfseries. + titleTruncate = '' % Useful when automatically generating page titles that may become too long, titleTruncate can be used to truncate a title (and subsequent subtitles) when they pass the specified number of characters. Default: .off. + orientation = '' % Paper orientation: Default: `portrait'. + footnote = {} % A footnote to be included at the bottom of this page. Default: none. + pageDirName = 'tmpRepDir' % The name of the folder in which to store this page. Only used when the latex command is passed. Default: tmpRepDir. + latex = '' % The valid LATEX code to be used for this page. Alows the user to create a page to be included in the report by passing LATEX code directly. Default: empty. + setPageNumber = '' % If true, reset the page number counter. Default: false. + removeHeaderAndFooter = false % Removes the header and footer from this page. Default: false. end methods function o = page(varargin) @@ -114,6 +115,8 @@ classdef page < handle '@page.page: sections is not a valid option'); assert(isempty(o.setPageNumber) || isint(o.setPageNumber), ... '@page.page: setPageNumber must be an integer'); + assert(islogical(o.removeHeaderAndFooter), ... + '@page.page: removeHeaderAndFooter must be boolean'); end end methods (Hidden = true) diff --git a/src/@page/write.m b/src/@page/write.m index cb361f4..a6ef0c2 100644 --- a/src/@page/write.m +++ b/src/@page/write.m @@ -35,6 +35,9 @@ fprintf(fid, '\n%% Page Number %d written %s\n', pg, datestr(now)); if ~isempty(o.setPageNumber) fprintf(fid, '\\setcounter{page}{%d}\n', o.setPageNumber); end +if o.removeHeaderAndFooter + fprintf(fid, '\\thispagestyle{empty}\n'); +end if strcmpi(o.orientation, 'landscape') fprintf(fid, '\\begin{landscape}\n'); end diff --git a/test/createReport.m b/test/createReport.m index 0830993..402a226 100644 --- a/test/createReport.m +++ b/test/createReport.m @@ -149,7 +149,8 @@ rep = CommResidTablePage(rep, db_q, dc_q, trange, dates('2012q2')); %% Commodities Graphs %Page 24 rep.addPage('title', 'Jan1 vs Jan2', ... - 'titleFormat', '\large\bfseries'); + 'titleFormat', '\large\bfseries', ... + 'removeHeaderAndFooter', true); rep.addSection('height', '0.475\textheight'); rep.addGraph('title', {'World Real Oil Price Index','SUBTITLE'}, ... -- GitLab