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 Version History

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 (2021). MATLAB Table to LaTeX conversor (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

Linas Minkevicius


Works great ! The fix of Jan Luca below worked very well (small detail: add "if isstring(value), value = value{1,1}; end" at the end of line 68)

Jan Luca

Did not work for strings for me. just added:
if isstring(value), value = value{1,1}; end
in line 69. Now working

Erik Nyström

Works great thank you

Aryan Ritwajeet Jha

Thanks a lot! While this program ran fine for me, it is Latex that is suceptible to any special character in a string from the MATLAB code.

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

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

Inspired: Data Uncertainty Format for LaTeX Table

Community Treasure Hunt

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

Start Hunting!