How to centre align a table with width>100%?
3 次查看(过去 30 天)
显示 更早的评论
With the report generator toolkit, I am trying to create a table that has a width of greater than 100% and then trying to align that to the centre or offset to the left so all the data fits into the page. How do I do this?
Data=array2table(Data,'VariableNames',String(1:7));
%convert the table and change some properties for
%aesthetics
Data=Table(Data);
%Data.RowNamesRule=false;
Data.Border='solid';
Data.ColSep='solid';
Data.RowSep='solid';
Data.HAlign='center';
%Data.OuterLeftMargin='1px'
Data.Width='105%';
Currently this just makes data pour over the right hand side like so:
I have already tried setting HAlign to centre or left and changing the left margin to a small number such as 1px, but that did not work. Any solutions?
0 个评论
回答(1 个)
Rahul Singhal
2018-10-11
If the Width of a Table is defined in percentage, it denotes the percentage of the page width it should take to render that table. So, a value greater than 100% will make the table overflow the page boundaries. I would suggest you to use a value less than 100% or use some fixed value, like '5in'.
If you do not wish to reduce the size of the table, you can also update the current page layout of your report to change orientation (make page landscape) or update page size, so that the page will be wide enough to render the table. Below links might be helpful.
For Report API reports see, https://www.mathworks.com/help/rptgen/ug/mlreportgen.report.report-class.html#d120e136826
For DOM API reports, see https://www.mathworks.com/help/rptgen/ug/mlreportgen.dom.document-class.html#budo6en-1_sep_shared-CurrentPageLayout
Starting R2018b, you can even slice your wide tables vertically into multiple slices, where each slice is small enough to fit legibly on a page, see https://www.mathworks.com/help/rptgen/ug/mlreportgen.utils.tableslicer-class.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title Pages, Tables of Contents, Lists of Figures, Tables, and Captions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!