Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to put this in a table inside my LaTeX document. How can I get this? Ctrl-K does it here but not sure how to do it in LaTeX.

               Left      Right     Bottom        Top   Diagonal
Left      0.1303394  0.1084274  0.2158028  0.1050394 -0.2093420
Right     0.1084274  0.1632741  0.2841319  0.1299967 -0.2404701
Bottom    0.2158028  0.2841319  2.0868781  0.1645389 -1.0369962
Top       0.1050394  0.1299967  0.1645389  0.6447234 -0.5496148
Diagonal -0.2093420 -0.2404701 -1.0369962 -0.5496148  1.3277163
share|improve this question
    
Do you want to display as code or as a properly-formatted table? –  Joseph Wright Sep 17 '12 at 18:43
    
Anything should help me.I need it the way I displayed it here. –  Vutukuri Sep 17 '12 at 18:47
6  
This is mostly a default construction in LaTeX. Consider perusing Tables in LATEX2ε: Packages and Methods which highlights many possibilities. –  Werner Sep 17 '12 at 19:00
add comment

2 Answers

up vote 8 down vote accepted

I would use the siunitx package for its ability to align numbers on their decimal points and display minus signs correctly and the booktabs package for its ability to draw well-spaced horizontal rules.

enter image description here

\documentclass{article}
\usepackage{siunitx,booktabs}
\sisetup{table-format=2.7, group-digits=false}
\begin{document}
\begin{table}
\centering
\caption{This is my table}
\begin{tabular}{@{} l *{5}{S} @{}} % use @{} to suppress space at ends of table
\toprule
& {Left} & {Right} & {Bottom} & {Top} & {Diagonal}\\ % center-set header entries
\midrule
Left    &  0.1303394  & 0.1084274 &  0.2158028 &  0.1050394 & -0.2093420\\
Right   &  0.1084274  & 0.1632741 &  0.2841319 &  0.1299967 & -0.2404701\\
Bottom  &  0.2158028  & 0.2841319 &  2.0868781 &  0.1645389 & -1.0369962\\
Top     &  0.1050394  & 0.1299967 &  0.1645389 &  0.6447234 & -0.5496148\\
Diagonal& -0.2093420  &-0.2404701 & -1.0369962 & -0.5496148 &  1.3277163\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
share|improve this answer
add comment
\begin{table}[h]
\centering
\begin{tabular}{lrrrrr}
       &      Left   &   Right  &   Bottom    &    Top  & Diagonal \\
\hline
Left     & 0.1303394 & 0.1084274 & 0.2158028 & 0.1050394 &-0.2093420 \\
Right    & 0.1084274 & 0.1632741 & 0.2841319 & 0.1299967 &-0.2404701 \\
Bottom   & 0.2158028 & 0.2841319 & 2.0868781 & 0.1645389 &-1.0369962 \\
Top      & 0.1050394 & 0.1299967 & 0.1645389 & 0.6447234 &-0.5496148 \\
Diagonal &-0.2093420 &-0.2404701 &-1.0369962 &-0.5496148 & 1.3277163 
\end{tabular}
\end{table}
share|improve this answer
    
I'd be tempted to use the array package to switch to math mode (or dcolumns, rccol or siunitx), as the -` will otherwise be wrong :-( –  Joseph Wright Sep 17 '12 at 19:48
    
@JosephWright you think you understand something, and when you least expect, you learn something new! I never new quite how to align the numbers properly, and now I know! Cheers for that. –  Vivi Sep 17 '12 at 20:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.