1

I'm using the below script to display the table, but it is not fitting in my page.

\begin{table}[h]
\begin{tabular}{l|lllllll}
\hline
sssssssss/sssss ss ssssssssss & sssssssss & ssssssss & ssssssss                                   & sssssssssss                 & ssssssssss & sssssssss ssss sssssssss ssssssssss & sssssssss ssss sssssssss ssssssssssss \\ \hline
sssss ssssssssssss            & sss       & sss      & sssssssss, ssssssssssss                    & sssssssss sssssss, sssssss  & ssssss     &                                     &                                         \\
ssssssssss ssssssssssss        & sss       & ss       & sssssssss                                  & ssssss ssssss              & ssssss     &                                     &                                         \\
ssssssss ssssssss             & ss        & sss      & sssssssss, sssssssss sssssssssss           & ssssssssssss, sssssssss    & ssssss     &                                     &                                         \\
ssss sssss                    & sss       & sss      & sssss, ssssssssss sssssss, ssssss ssssssss & ssssssssssss               & sssssss    &                                     &                                         \\
ssss                          & ss        & sss      & sssssss ssssss, sssssssss ssssssss         & sssssssss                  & sssssss    &                                     &                                         \\
sss                           & ss        & sss      & ssssssss ssssssssss                        & sssss sssssssss            & sssssss    &                                     &                                         \\
ssssss ssssss                 & ss        & sss      & ssssssss ssssssssss                        & sssssssss ss sssss sssssss & sssssss    &                                     &                                        
\end{tabular}
\end{table}

And this is my document class used:

\documentclass[12pt]{report}
  • It doesn't fit within the page because the table is too wide. If you tell latex to create a table with column content that will make it spill over, there's nothing it can do about that (what should it do about it?). – Sverre May 20 '15 at 15:21
2

LaTeX is brilliant and unparalleled in its field; but it's not magical. It typesets the table it's given; it can't know that you don't intend that table to extend past the margins unless you tell it so.

To control the overall width of a table, you can use tabularx; its documentation is clear and complete, but the bottom line is you can change your column specifier to X, and that column will stretch or shrink to allow the table to fit. In your table, columns 1, 3, and 4 seem to be the issues; so:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\linewidth}{X|lXXXXXX}
\hline
sssssssss/sssss ss ssssssssss & sssssssss & ssssssss & ssssssss                                   & sssssssssss                 & ssssssssss & sssssssss ssss sssssssss ssssssssss & sssssssss ssss sssssssss ssssssssssss \\ \hline
sssss ssssssssssss            & sss       & sss      & sssssssss, ssssssssssss                    & sssssssss sssssss, sssssss  & ssssss     &                                     &                                         \\
ssssssssss ssssssssssss        & sss       & ss       & sssssssss                                  & ssssss ssssss              & ssssss     &                                     &                                         \\
ssssssss ssssssss             & ss        & sss      & sssssssss, sssssssss sssssssssss           & ssssssssssss, sssssssss    & ssssss     &                                     &                                         \\
ssss sssss                    & sss       & sss      & sssss, ssssssssss sssssss, ssssss ssssssss & ssssssssssss               & sssssss    &                                     &                                         \\
ssss                          & ss        & sss      & sssssss ssssss, sssssssss ssssssss         & sssssssss                  & sssssss    &                                     &                                         \\
sss                           & ss        & sss      & ssssssss ssssssssss                        & sssss sssssssss            & sssssss    &                                     &                                         \\
ssssss ssssss                 & ss        & sss      & ssssssss ssssssssss                        & sssssssss ss sssss sssssss & sssssss    &                                     &                                        
\end{tabularx}
\end{table}
\end{document}

Now, your table still doesn't look very good; since there are very few word breaks, it's impossible for LaTeX to select good break points for the columns. But this should give you the idea.

You can also consider setting your table in landscape mode (see the lscape package), or reducing the size of the text, though in the latter case you should be careful you're not making a stylistic mistake.

Also, please include a minimal working example in your question, that people can simply copy, paste, and compile, complete with \documentclass and the rest; this makes it much easier for people to help you. A quick search will reveal more information about this.

0

I'm using my one package "simpltex"

It works for me :

\tab<0mm><-3cm>[p{0.14\textwidth} | *{7}{p{0.14\textwidth}}]
{
sssssssss sssss / ss ssssssssss & sssssssss & ssssssss & ssssssss & sssssssssss & ssssssssss & sssssssss ssss sssssssss ssssssssss & sssssssss ssss sssssssss ssssssssssss
\row
sssss ssssssssssss & sss & sss & sssssssss, ssssssssssss & sssssssss sssssss, sssssss  & ssssss & &
\row
ssssssssss ssssssssssss & sss  & ss & sssssssss & ssssss ssssss & ssssss & &
\row
ssssssss ssssssss & ss & sss & sssssssss, sssssssss sssssssssss & ssssssssssss, sssssssss & ssssss & &
\row
ssss sssss & sss & sss & sssss, ssssssssss sssssss, ssssss ssssssss & ssssssssssss & sssssss & &
\row
ssss & ss & sss & sssssss ssssss, sssssssss ssssssss & sssssssss & sssssss & &
\row
sss & ss & sss & ssssssss ssssssssss & sssss sssssssss & sssssss & &
\row
ssssss ssssss & ss & sss & ssssssss ssssssssss & sssssssss ss sssss sssssss & sssssss & &
}

(https://github.com/adrien-zinger/simple-latex)

Your Answer

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

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