File Exchange

image thumbnail

MATLAB Table to LaTeX conversor

version 1.1.4 (2.16 KB) by Víctor Martínez-Cagigal
This function converts a MATLAB(R) table into a .tex file, using LaTeX formatting.


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 (, 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.

Shaoni Nandi

How to fix decimal places for tables?

Mario González

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.



Rui Coelho

Fred Lima

shdotcom shdotcom

Thanks for sharing



Infinite values are now supported.




Error detection.




Function now supports tables with RowNames.

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