Printing a formatted table

Allows to display and print simple text tables in MatLab. Plain and LaTeX format supported.

2.6K Downloads

Updated 27 Jul 2015

View License

@@ ATTENTION @@
I've merged my separate submissions into KerMor/matlabtools (http://de.mathworks.com/matlabcentral/fileexchange/52299-kermor-matlabtools), which contains this submission. Please refer to that package to retrieve the current status.
@@@@
This class allows to display and print a table with arbitrary number of columns.

The first row can be distinguished from others by a HasHeader flag and the column separator string can be customized.

Basic automatic conversion allows to pass common, easily string-representable data types, and optionally sprintf-compatible format strings or callbacks can be passed for either all entries or entry-specific.

Optionally a caption can be added to the PrintTable upon construction, directly taking sprintf-like arguments.

Allows to save the table in the formats 'txt' (plain text), 'tex' (LaTeX tabular) and 'pdf' (Basically using pdflatex on 'tex' output).

The table can easily be transposed and sorted.

In difference to the submission #33717 I make use of classes and have more possibilities regarding output and appearance.

Now a basic automatic $Math$-Environment detection for LaTeX is available.

Cite As

Daniel Wirtz (2023). Printing a formatted table (https://www.mathworks.com/matlabcentral/fileexchange/33815-printing-a-formatted-table), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.19.0.0

I've merged my separate submissions into KerMor/matlabtools (http://de.mathworks.com/matlabcentral/fileexchange/52299-kermor-matlabtools), which contains this submission. Please refer to that package to retrieve the current status.
Added a simple "sort" function

1.18.0.0

Bugfix for PrintTable LaTeX Table generation (printTex would throw an error sometimes)

1.16.0.0

- Stripping newlines automatically
- Soem verbose comments for LaTeX output about creating script

1.15.0.0

- bugfix for $$ wrapping also in txt mode
- added "append" method to join two tables

1.14.0.0

-New property "TexMathModeDetection" for cell content wrapping with $$
-New property "StripInsertedTabChars" for automatic stripping of tab chars
- Added a short comment of the applied settings to LaTeX output.
- Smaller improvements

1.13.0.0

Improved compatibility (no more wiggles ~)

1.12.0.0

Improved automatic TabCharLength computation

1.9.0.0

- More datatypes handled for "stringification"
- No more table title for TightPDF LaTeX export (one line)

1.8.0.0

- Added a ctranspose overload
- TabCharLen now public property
- Small fixes

1.5.0.0

-Saving to PDF now possible
-Option "TightPDF" for pdf to contain only actual table or be an article page
-HasRowHeader tag for easy formatting of non-first column entries
-Constructor takes caption with sprintf-arguments
-Bugfixes, Demos

1.4.0.0

Fixed some bugs and added LaTeX format output and optional captions to the PrintTable.

1.0.0.0