From 6a9e9dfdea9248e67ea576228ca7c82f3e8334a7 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Wed, 25 Sep 2013 15:25:34 +0200
Subject: [PATCH] reporting: new table option vlineAfterEndOfPeriod

---
 doc/dynare.texi               |  6 +++++-
 matlab/reports/@table/table.m |  3 +++
 matlab/reports/@table/write.m | 20 ++++++++++++++------
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/doc/dynare.texi b/doc/dynare.texi
index c99e583b3d..280695f76c 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -8421,7 +8421,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, showVlines
+@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleSize, vlineAfter, vlineAfterEndOfPeriod, showVlines
 Adds a @code{Table} to a @code{Section}.
 @optionshead
 @table @code
@@ -8450,6 +8450,10 @@ Title for the table. Default: @code{none}
 @item vlineAfter, @code{dynDate}
 Show a vertical line after the specified date. Default: @code{empty}
 
+@item vlineAfterEndOfPeriod, @code{BOOLEAN}
+Show a vertical line after the end of every period (@i{i.e.} after
+every year, after the fourth quarter, etc.). Default: @code{false}
+
 @item showVlines, @code{BOOLEAN}
 Whether or not to show vertical lines separating the columns. Default: @code{false}
 @end table
diff --git a/matlab/reports/@table/table.m b/matlab/reports/@table/table.m
index 55cdde174d..ce3808eeb5 100644
--- a/matlab/reports/@table/table.m
+++ b/matlab/reports/@table/table.m
@@ -39,6 +39,7 @@ o.titleSize = 'large';
 o.showHlines = false;
 o.showVlines = false;
 o.vlineAfter = '';
+o.vlineAfterEndOfPeriod = false;
 
 o.data = '';
 o.seriesToUse = '';
@@ -87,6 +88,8 @@ assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
 if o.showVlines
     o.vlineAfter = '';
 end
+assert(islogical(o.vlineAfterEndOfPeriod), ...
+       '@table.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)), ...
diff --git a/matlab/reports/@table/write.m b/matlab/reports/@table/write.m
index afb47f16b9..82ba6233f7 100644
--- a/matlab/reports/@table/write.m
+++ b/matlab/reports/@table/write.m
@@ -55,12 +55,20 @@ fprintf(fid, '\\begin{tabular}{@{}l');
 
 for i=1:ndates
     if o.showVlines
-        fprintf(fid, '|');
-    end
-    fprintf(fid, 'r');
-    if ~isempty(o.vlineAfter)
-        if dates(i) == o.vlineAfter
-            fprintf(fid, '|');
+        fprintf(fid, 'r|');
+    else
+        fprintf(fid, 'r');
+        if o.vlineAfterEndOfPeriod
+            if dates(i).time(2) == dates(i).freq
+                fprintf(fid, '|');
+            end
+        end
+        if ~isempty(o.vlineAfter)
+            if dates(i) == o.vlineAfter
+                if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq)
+                    fprintf(fid, '|');
+                end
+            end
         end
     end
 end
-- 
GitLab