Exporting a live script as a pdf renders tables with an inconsistent format
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
dpb
on 13 Feb 2026
I 'know nuthink!' about the live editor and definitely no ideas about exporting to pdf inside it, but surely you don't need that many significant digits, do you? How are you preparing the table in MATLAB code to start with? What if you set
format shortG
first?
dpb
on 14 Feb 2026
format long;
"right at the top of the file..."
Yes, that causes the large number of digits, but is it actually a stated requirement of the assignment?
Never using live scripts, and the few times I've attempted the interface isn't at all intuitive (to me at least) I dunno.
I did some report building with the report generator and when stuck on how to accomplish something found the AI 'bot generally gave sufficient guidance that could then at least find the relevant documentation even if the code itself didn't work. If it isn't prohibited by your ground rules, mmight try that to see what hints it might provide.
Julian
on 14 Feb 2026
The 'bot says you can adjust the column widths interactively in the live script and the pdf doc will honor those. Have you tried that?
Otherwise, <old threads on Answers? are that only programmatic way would be to use the DOM report generator which is undoubtedly ouf of scope for a homework assignment unless it is on using report generator.
Julian
on 14 Feb 2026
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.
Julian
on 14 Feb 2026
Accepted Answer
More Answers (0)
Categories
Find more on Bar Plots 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!