From 85ea29e1a800d0d355ef90033f9fe93a5353177c Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Fri, 19 Apr 2013 18:21:59 +0200
Subject: [PATCH] reporting: @graph: write title directly in latex file (as
 opposed to Matlab plot).

If you don't do this, the title will be centered over the plot (not including YTickLabel width) as opposed to within the cell. This can be weird if you have one table in the section as the plot title will not center with the page title.
---
 matlab/reporting/@graph/createGraph.m | 4 ----
 matlab/reporting/@graph/write.m       | 8 ++++++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m
index 919bde1578..a511840774 100644
--- a/matlab/reporting/@graph/createGraph.m
+++ b/matlab/reporting/@graph/createGraph.m
@@ -114,10 +114,6 @@ end
 if ~isempty(o.ylabel)
     ylabel(['$\textbf{\footnotesize ' o.ylabel '}$'], 'Interpreter', 'LaTex');
 end
-
-if ~isempty(o.title)
-    title( o.title, 'Interpreter', 'LaTex');
-end
 drawnow;
 
 o.figname = [tempname '.tex'];
diff --git a/matlab/reporting/@graph/write.m b/matlab/reporting/@graph/write.m
index bce88cf3fc..9078b0283b 100644
--- a/matlab/reporting/@graph/write.m
+++ b/matlab/reporting/@graph/write.m
@@ -34,7 +34,15 @@ if isempty(o.figname)
     o = createGraph(o);
 end
 
+if ~isempty(o.title)
+    fprintf(fid,'\\begin{tabular}[x]{@{}c@{}}%s\\\\',o.title);
+end
+
 if ~isempty(o.figname)
     fprintf(fid, '\\input{%s}', o.figname);
 end
+
+if ~isempty(o.title)
+    fprintf(fid,'\\end{tabular}',o.title);
+end
 end
\ No newline at end of file
-- 
GitLab