# Dificult using LTXtable

I have a script in R that build a report in LaTeX. Sometimes, this report has very long and very wide table, so, after some research I decided try ltxtable. My problem is that I didn't get how it works.

I have this LaTeX code for the report:

\documentclass{report}
\usepackage{ltxtable, tabularx, longtable}
\usepackage[latin1]{inputenc}
\title{CP 68 - Estatístico}
\author{Rodrigo Coster - 1141783-01}
\begin{document}
\textbf{ \begin{center}{\LARGE Informações referentes ao CP 68 - Estatístico }\end{center} }
\section*{Informações sobre processos}
\LTXtable{\textwidth}{'table.tex'}
\section*{Informações sobre fila de espera}
Este CP não possui mais candidatos habilitados.
\end{document}


And, in the same folder, the file table.tex:

\begin{longtable}{|c|c|c|c|c{1cm}|}
\begin{center}
\hline
\textbf{\textbf{Processo}} & \textbf{Vagas} & \textbf{Data} & \textbf{Convocados} & \textbf{Exercicio ok} \\ \hline
\textbf{001.010726.12.8} & 2 & 13/04/2012 & 2 & 2 \\ \hline
\end{center}
\end{longtable}


After run, in console appears:

("C:\relatorios\Concursos\20130312 - CP 68 - Estatistico.aux")
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
Enter file name:


I tried a lot of file names. For most of them, he ask for the name again. If I type table.tex I get this error:

(C:\relatorios\Concursos\table.tex
! Missing # inserted in alignment preamble.
&
l.1 \begin{longtable}{|c|c|c|c|c{1cm}|}

?


I already tried put \begin{center} in the first line, but didn't work.

EDIT:

Anothe table.tex:

\begin{longtable}{|c|c|c|c|c|c|}
\hline
\textbf{\textbf{Área}} & \textbf{Convocados} & \textbf{Não ingressou} & \textbf{Para convocar} & \textbf{Manifestou interesse} & \textbf{Exercicio ok} \\ \hline
\textbf{Administração e economia               } &   8 &  6 & 0 &  0 &   2 \\ \hline
\textbf{Anos iniciais dos ciclos de formação   } & 474 & 80 & 0 & 13 & 381 \\ \hline
\textbf{Artes visuais                          } &  45 &  8 & 2 &  2 &  33 \\ \hline
\textbf{Biologia                               } &   1 &  0 & 0 &  0 &   1 \\ \hline
\textbf{Ciências da computação                 } &   2 &  1 & 0 &  0 &   1 \\ \hline
\textbf{Ciências físicas, químicas e biológicas} &  72 & 12 & 0 &  1 &  59 \\ \hline
\textbf{Ciências sócio-históricas              } &  48 & 11 & 0 &  2 &  35 \\ \hline
\textbf{Dança                                  } &  17 &  6 & 0 &  0 &  11 \\ \hline
\textbf{Deficiência mental                     } &  40 &  5 & 0 &  0 &  35 \\ \hline
\textbf{Deficiência visual                     } &   4 &  1 & 0 &  0 &   3 \\ \hline
\textbf{Educação de surdos                     } &   6 &  3 & 0 &  0 &   3 \\ \hline
\textbf{Educação física/rede escolar           } & 134 & 26 & 0 &  1 & 107 \\ \hline
\textbf{Educação infantil                      } & 123 & 17 & 1 &  2 & 103 \\ \hline
\textbf{Filosofia                              } &   7 &  0 & 0 &  0 &   7 \\ \hline
\textbf{Física                                 } &   1 &  0 & 0 &  0 &   1 \\ \hline
\textbf{Geografia                              } &  56 & 15 & 1 &  2 &  38 \\ \hline
\textbf{História                               } &  51 & 15 & 0 &  0 &  36 \\ \hline
\textbf{Língua espanhola                       } &  33 &  8 & 0 &  1 &  24 \\ \hline
\textbf{Língua francesa                        } &   3 &  1 & 0 &  0 &   2 \\ \hline
\textbf{Língua inglesa                         } &  38 &  9 & 1 &  0 &  28 \\ \hline
\textbf{Língua portuguesa                      } &  81 & 22 & 1 &  0 &  58 \\ \hline
\textbf{Matemática                             } & 104 & 26 & 1 &  1 &  76 \\ \hline
\textbf{Música                                 } &  51 & 17 & 0 &  1 &  33 \\ \hline
\textbf{Teatro                                 } &   5 &  0 & 0 &  0 &   5 \\ \hline
\end{longtable}

• You can not put \begin{center} inside longtable )or any other latex tabular environment Justdelete those lines. c{1cm} is also a syntax error latex c columns do not take a length parameter. Mar 12 '13 at 17:13
• If this is primarily a table of numeric data you do not want ltxtable/tabularx as that allows entries in a column to wrap over several lines but you can not do line breaking in numbers. Mar 12 '13 at 17:15
• @DavidCarlisle I removed the \begin{center}, \end{center} and {1cm}. Now it ask the file name several times (actualy, 4). After the 4th, the .pdf file is created (and with the table! \o/). You know why (and how to solve)? My problem with the width is in the title line (some tables has more than 5 columns) Mar 12 '13 at 17:21
• Probably the quotes are confusing things try changing {'table.tex'} to {table} But ltxtable will do nothing on this example other than be slower than a normal tabular. see this for ways of making tables narrower tex.stackexchange.com/questions/101748/… Mar 12 '13 at 17:28
• It worked! I added another table.tex, with more columns. I read you post, but didn't get how to adapt it to ltxtable :/ Mar 12 '13 at 17:46

There is no need for that table to be wide, you just need to make sure the table width is not dominated by the headers. It is much better to do that by hand than rely on tabularx / ltxtable which knows nothing about the table structure.

here I rotated the headings but there are other possibilities:

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{longtable,graphicx,array}

\begin{document}

\begin{longtable}{|>{\bfseries\raggedright}p{5cm}|c|c|c|c|c|}
\hline
Administração e economia              &   8 &  6 & 0 &  0 &   2 \\ \hline
Anos iniciais dos ciclos de formação  & 474 & 80 & 0 & 13 & 381 \\ \hline
Artes visuais                         &  45 &  8 & 2 &  2 &  33 \\ \hline
Biologia                              &   1 &  0 & 0 &  0 &   1 \\ \hline
Ciências da computação                &   2 &  1 & 0 &  0 &   1 \\ \hline
Ciências físicas, químicas e biológicas &  72 & 12 & 0 &  1 &  59 \\ \hline
Ciências sócio-históricas             &  48 & 11 & 0 &  2 &  35 \\ \hline
Dança                                 &  17 &  6 & 0 &  0 &  11 \\ \hline
Deficiência mental                    &  40 &  5 & 0 &  0 &  35 \\ \hline
Deficiência visual                    &   4 &  1 & 0 &  0 &   3 \\ \hline
Educação de surdos                    &   6 &  3 & 0 &  0 &   3 \\ \hline
Educação física/rede escolar          & 134 & 26 & 0 &  1 & 107 \\ \hline
Educação infantil                     & 123 & 17 & 1 &  2 & 103 \\ \hline
Filosofia                             &   7 &  0 & 0 &  0 &   7 \\ \hline
Física                                &   1 &  0 & 0 &  0 &   1 \\ \hline
Geografia                             &  56 & 15 & 1 &  2 &  38 \\ \hline
História                              &  51 & 15 & 0 &  0 &  36 \\ \hline
Língua espanhola                      &  33 &  8 & 0 &  1 &  24 \\ \hline
Língua francesa                       &   3 &  1 & 0 &  0 &   2 \\ \hline
Língua inglesa                        &  38 &  9 & 1 &  0 &  28 \\ \hline
Língua portuguesa                     &  81 & 22 & 1 &  0 &  58 \\ \hline
Matemática                            & 104 & 26 & 1 &  1 &  76 \\ \hline
Música                                &  51 & 17 & 0 &  1 &  33 \\ \hline
Teatro                                &   5 &  0 & 0 &  0 &   5 \\ \hline
\end{longtable}

\end{document}
`

Just a simple typography tip, as I liked David's technical answer but not the looks (I don't like to turn my head to read headers). Although also not a very good solution you can use abbreviations, turn the table data around or use symbols (which you can explain in the caption or in the text).

• Yes I'd have probably suggested abbreviating the headers but I wasn't sure what they all meant so rotating them was linguistically safer:-) (+1) Mar 12 '13 at 18:58
• @DavidCarlisle Sure maybe Paul can translate them for us:) Mar 12 '13 at 19:01