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.

My table has 25 columns I think and how can I make each column smaller and make the table fit on one page ?

\documentclass[9pt]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{tabularx}% http://ctan.org/pkg/tabularx

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{l|lllllllllllllllllllllllll p{10cm}}

    Shifts/Time & 8     & 9     & 10    & 11    & 12    & 13    & 14    & 15    & 16    & 17    & 18    & 19    & 20    & 21    & 22    & 23    & 24    & 1     & 2     & 3     & 4     & 5     & 6     & 7 \\
     \hline \hline

    A1    & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    A2    & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    B1    & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    B2    & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    C1    & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    C2    & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    D1    & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    D2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    E1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    E2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    F1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0 \\
    F2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0 \\
    G1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0 \\
    G2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0 \\
    H1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0 \\
    H2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0 \\
    I1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1 \\
    I2    & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1 \\

    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%


\end{document}
share|improve this question
    
Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). –  Marco Daniel May 10 '13 at 11:04
    
Found something that worked for me use this \usepackage[margin=0.5in]{geometry} –  kjartan May 10 '13 at 11:09
add comment

2 Answers

Just reduce the font size, and also the inter-column space The last column didn't seem to need 10cm so I made that l to match the others.

enter image description here

Note article does not have a 9pt option.

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{tabularx}% http://ctan.org/pkg/tabularx

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
 \small
  \setlength\tabcolsep{3pt}
  \caption{Add caption}
    \begin{tabular}{l|llllllllllllllllllllllllll}
\begin{tabular}{@{}l@{}}Shifts/\\Time\end{tabular}
& 8     & 9     & 10    & 11    & 12    & 13    & 14    & 15    & 16    & 17    & 18    & 19    & 20    & 21    & 22    & 23    & 24    & 1     & 2     & 3     & 4     & 5     & 6     & 7 \\
     \hline \hline

    A1    & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    A2    & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    B1    & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    B2    & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    C1    & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    C2    & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    D1    & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    D2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    E1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    E2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0 \\
    F1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0     & 0 \\
    F2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0     & 0     & 0 \\
    G1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0     & 0     & 0 \\
    G2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0     & 0     & 0 \\
    H1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1     & 0     & 0 \\
    H2    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1     & 1     & 0 \\
    I1    & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 1     & 1     & 0     & 1     & 1     & 1 \\
    I2    & 1     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 0     & 1     & 1     & 0     & 1     & 1     & 1     & 1 \\

    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}
share|improve this answer
add comment

If you don't mind shifting one page of your document to landscape view, try the sidewaystable environment. You'll need to add the rotating package to your preamble.

share|improve this answer
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.