6
$\begingroup$

Is it possible to export a matrix to $\LaTeX$ with style?

For example this code will create a matrix with equal spacing matrix and with background colors in some cell, is it possible to export that to $\LaTeX$ ?

tb = Table[RandomInteger[{0, 10}], {10}, {10}];
Grid[tb, Dividers -> {{{{True, False}}, {-1 -> False, 
     1 -> False}}, {{{True, False}}, {-1 -> False, 1 -> False}}}, 
 ItemSize -> {4.5, 4}, Spacings -> {0, 0}, 
 Background -> {Automatic, Automatic, 
   Flatten@{Table[{{2 i + 1, 2 i + 2}, {2 i + 1, 2 i + 2}} -> 
       Green, {i, 0, 4}], 
     Table[{{2 i + 1, 2 i + 2}, {2 i - 1, 2 i}} -> Pink, {i, 1, 4}], 
     Table[{{2 i - 1, 2 i}, {2 i + 1, 2 i + 2}} -> Pink, {i, 1, 4}]}}] 

enter image description here

I tried to copy as $\LaTeX$ and Export["~/1.tex",%], both only give the matrix content without any formattings.

$\endgroup$
  • 5
    $\begingroup$ A general-purpose way of getting useable $\LaTeX$ code is to Export as PDF, then import into Inkscape and from there choose Save As > LaTeX with PSTricks Macros. That produces a .tex fragment which can go into the body of a host file as long as the latter calls \usepackage{pstricks} first. This isn't specific to tables, it works for anything that can be exported as PDF. For specific things like tables, it's also possible to generate the $\LaTeX$, but only by hand-coding it. $\endgroup$ – Jens Apr 29 '13 at 0:54
  • 1
    $\begingroup$ Please take a look at this post. $\endgroup$ – Rod Apr 29 '13 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.