File Exchange

image thumbnail

LaTeX table creation.

version 1.0 (4.59 KB) by

Function for converting numeric or cell arrays to LaTeX table.

11 Ratings

1 Download


View License

This function was designed to be tool for converting MATLAB 2D arrays into a LaTeX tabular environment. It includes the ability to add horizontal and vertical labels, alter the data format, insert horizontal and vertical lines, as well as load and save settings.

Information regarding operate the function are contained in the comments, but here is a quick example:
>> latextable(rand(3,3),'Horiz',{'1','2','3'},'Hline',[0,1,NaN]);

I hope this function is useful for some people. I am sure there are probably a few bugs, so please let me know if you find any problems.

Comments and Ratings (12)

Patrick Laux

Sorry, my mistake. I had the file twice and hardcoded the format in the other file. I give you 5 stars!!


Rudy (view profile)


Kerry (view profile)

Works neatly and as advertised.
One suggested option: return the LaTeX table string without saving to file. This is useful for including in the table in a matlab annotation, for example.
Note for anyone using the file output as the string in a matlab annotation: you may need to remove the newline characters first. For example,
worked for me.


Daniel (view profile)

It does exactly (and no more than) what you almost tried to implement on your own. Thanks!


Sven (view profile)

Excellent submission. There are some improvements that would help the kind of person that uses latex/matlab (ie, people who like to automate things).

Please consider simply adding the table string as simply the output to the latextable() function. This would help people (like me) who don't actually want the whole preamble (the \begin{table} stuff with headers and the \end{table} part too).

For example, I've got some pretty complex header cells with merged cells that I can just hardcode in my document once, but I want to re-run my analysis and have the document update nicely. I don't expect MATLAB to handle the complex headering, but I would like it to just spit out the main table data, and I can get my latex file to import these contents _after_ the hard-coded header lines.


Jud (view profile)

Very nice. Much better than matrix2latex.m, because the row and column labels actually work !


Niklas (view profile)

exactly what i was looking for. cheers!

Tim Fairlow

Works well, thanks!


Alan (view profile)


Daniel (view profile)

It is a pretty interesting function, but actually not what i was looking forward. I am trying to find a way to tipe in tex characters as headers of uitable (for GUI).

For example to be able to introduce greek characters as headers of columns and so on. I think that it is only possible to do this for figure right?

It would be awsome if anyone could give me a hand on that. And congratulations for the functions, i just wrote my Thesis with matlab and im sure it will help many other people.



Sener (view profile)

good job.. keep it up

MATLAB Release
MATLAB 7.7 (R2008b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today