Tables in LaTeX

Ok… I have most definitely gone over the bend, LaTeX tables are a pain, at least till you know how to do them… I have been trying to add neat tables to LaTeX documents, and I have been searching all kinds of places. But I have finally found something that seems to work.

It has one last slight problem: If you have a column with so much text that it should span onto more than one page, then TeX system will sadly just make it overlong.

But otherwise, here is how I did it. First the document begins:

\documentclass{scrartcl}
\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{ltxtable}
\begin{document}
\section{Title}

Now these are the first lines needed and will be in the main document .tex file.
The actual table must be in a different file and will then be added with this command in the main document:

\LTXtable{\textwidth}{table.tex}

Now in the table.tex file as is included in the above line we add the table as follows:

\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\renewcommand{\arraystretch}{1.5}
\noindent \begin{longtable}{|>{\setlength\hsize{.5\hsize}}X|>{\setlength\hsize{1.5\hsize}}X|}
\caption{Some table} \\
\hline
Lorem & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. sdfsdfsfsdfs dfg dfg\\
Lorem & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. sdfsdfsfsdfs dfg dfg\\
Lorem & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. sdfsdfsfsdfs dfg dfg\\
\hline
\end{longtable}

After that is done, our table is included and will automatically span to different pages, as well as have a specified column width.
This column width in this example is made to be the full textwidth of the page, as described in the

\LTXtable{\textwidth}{table.tex}

line.

In the

\begin{longtable}{|>{\setlength\hsize{.5\hsize}}X|>{\setlength\hsize{1.5\hsize}}X|}

line of the table definition/environment we can see that our second column is three times as wide as the first column. It is important, that the some of the columns NEVER be more than number of columns in the text.

In the following links one will find the pdfs to files I found on the net to tables in LaTeX. They helped me quite a bit.

Tables in LaTeX

Typesetting tables with LATEX