### Highlights from LaTeX table creation.

Join the 15-year community celebration.

Play games and win prizes!

4.8
4.8 | 10 ratings Rate this file 11 Downloads (last 30 days) File Size: 4.59 KB File ID: #24387 Version: 1.0

# LaTeX table creation.

by

### Andrew (view profile)

Function for converting numeric or cell arrays to LaTeX table.

File Information
Description

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.

MATLAB release MATLAB 7.7 (R2008b)
05 Jun 2014 Rudy

### Rudy (view profile)

02 Jun 2014 Kerry

### Kerry (view profile)

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,
str(str==10)=[];
worked for me.

09 Oct 2013 Daniel

### Daniel (view profile)

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

18 Jan 2013 Sven

### 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.

20 Sep 2011 Jud

### Jud (view profile)

18 Jun 2010 Julien Emile-Geay

### Julien Emile-Geay (view profile)

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

21 Apr 2010 Niklas

### Niklas (view profile)

exactly what i was looking for. cheers!

07 Oct 2009 Tim Fairlow

### Tim Fairlow (view profile)

Works well, thanks!

26 Sep 2009 Alan

### Alan (view profile)

16 Sep 2009 Daniel

### 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.

Greets!

Comment only
12 Jun 2009 Sener

### Sener (view profile)

good job.. keep it up