Exporting a live script as a pdf renders tables with an inconsistent format
49 views (last 30 days)
Show older comments
Hi everyone,
I'm trying to export a live script to a PDF for one of my assignments, but the format of tables that MATLAB renders is inconsistent. With some tables, each numerical value is displayed on one line, while with others, the last digit of the number is split on a second line within the cell. In both cases, the table does not fill the entire page space. I see that I can adjust the column widths manually in the live script, but I was wondering if there is a more succinct way to render the tables so that the numbers are not split across multiple lines.
Attached are screenshots of the correct and incorrectly formatted tables, as well as my export settings.
Any help is appreciated.
8 Comments
DGM
on 14 Feb 2026 at 14:49
Edited: DGM
on 14 Feb 2026 at 14:52
Using format long is similar to using %g with fprintf() in that it does not strictly ensure a fixed field width. It will use fewer digits when it can.
format long
x = (1:3).';
y = [pi 2 2.5].';
table(x,y)
Note that the round-trip conversion (decimal-float64-decimal) of both 2 and 2.5 are exactly representable with fewer digits than the field width implied by something which cannot. This is an emphatic example, but sometimes it cuts neatly at a different number of digits.
That said, I don't know anything about using live scripts, the report generator, or any versions released in the last few years. I'm just suggesting that maybe tailored formatting requirements might need a bit more deliberate construction.
Accepted Answer
Julian
on 14 Feb 2026 at 14:36
3 Comments
dpb
on 14 Feb 2026 at 16:45
Edited: dpb
on 14 Feb 2026 at 17:39
"...manually adjust every column in every table, of which there are quite a few...."
OK. I also made an unwarranted assumption that for a homework assignment there would be just one or two and one might as well just fixup the table(s) in the script while solving the rest of the problem.
I don't disagree at all about presentation affecting perception; that's what peeved me with reporting results to clients taking so much time to clean up things.
The format long is a real pita kind of thing to put into a script imo -- I don't know that in 30+ years using MATLAB I've ever used it for anything other than debugging things like rounding errors and the like; it's just never possible that more than 5-6 figures can ever be truly significant except, perhaps, in the bowels of some sensitive numerical algorithm.
My thinking is and have suggested to Mathworks the table should be customizable by variable format but so far, not gotten that far even with the uitable. The only way at present to gain more control than the global format setting is as @DGM noted, write a specific format which then means the data in the table itself must all be text, not numeric which is awkward at best.
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!