File Exchange

image thumbnail

MATLAB Table to LaTeX conversor

This function converts a MATLAB(R) table into a .tex file, using LaTeX formatting.

60 Downloads

Updated 22 Oct 2018

View License

The function table2latex(T, filename) formats a MATLAB table (T) into a .tex file (specified by the filename path), following the LaTeX formatting. Please, avoid using cells or structs inside the table.

Cite As

Víctor Martínez-Cagigal (2020). MATLAB Table to LaTeX conversor (https://www.mathworks.com/matlabcentral/fileexchange/69063-matlab-table-to-latex-conversor), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Maria M.

Thank you for sharing. Though for the merged columns, script saves only the first one.

How to fix decimal places for tables?

Thanks for sharing this function

Hi Victor, I added the following lines to include variable units on the header of the LaTeX table:

% Parameters
unit_names = strjoin(T.Properties.VariableUnits, ' & ');

% Writing header
% Writing header
fileID = fopen(filename, 'w');
fprintf(fileID, '\\begin{tabular}{%s}\n', col_spec);
fprintf(fileID, '%s \\\\ \n', col_names);
fprintf(fileID, '%s \\\\ \n', unit_names);
fprintf(fileID, '\\hline \n');

Hope this code will be of use, and can be pulled to a next revision of the function.

Thanks!

-Gaston

Rui Coelho

Fred Lima

Thanks for sharing

Updates

1.1.4

Infinite values are now supported.

1.1.3

.

1.1.2

Error detection.

1.1.1

Grammar.

1.1.0

Function now supports tables with RowNames.

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