Graphics, Figures & TablesTabularx - many errors

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kettu_lissa
Posts: 5
Joined: Mon Jun 19, 2023 12:00 am

Tabularx - many errors

Post by kettu_lissa »

Hello! I'm trying to make a table for my final project but I've been dealing with many types of problems...
Since it's so many, I need to try to fix them little by little. I have tried to find answers in different wesbites but got no sucess when trying to fix my code...

My first question, is to understand what's going on on this code. In this one, I left only the columns (5 columns) to see if I still get the errors and stil get them:

Code: Select all

\begin{table}  % If I don't nest tabularx inside a table, I get the same errors, nothing changes...
    \begin{tabularx}{\textwidth}{c|c|c|c|c}

    \hline
    Atributo & Nome & Definição & Obrigatório? & Instruções   % columns ...                                       
    \hline
    
    \end{tabularx} % The errors are pointingto this line...
\end{table}
I get the following errors:

- Missing number, treated as zero.
- Misplaced \noalign.
- Underfull \hbox (badness 10000) in alignment at lines 41--41
- You can't use `\hrule' here except with leaders.
- Illegal unit of measure (pt inserted).


Thank you! :D

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Tabularx - many errors

Post by Bartman »

Please try to make a complete Infominimal working example.

Start, e.g. with the \\ macro, a new table row before the \hline command or one of the booktabs package commands draws a horizontal line. It should be mentioned in a LaTeX introduction because it's part of the basic knowledge.

Why did you choose the tabularx environment without using its special column type?
kettu_lissa
Posts: 5
Joined: Mon Jun 19, 2023 12:00 am

Tabularx - many errors

Post by kettu_lissa »

Bartman wrote:Please try to make a complete Infominimal working example.

Start, e.g. with the \\ macro, a new table row before the \hline command or one of the booktabs package commands draws a horizontal line. It should be mentioned in a LaTeX introduction because it's part of the basic knowledge.

Why did you choose the tabularx environment without using its special column type?
Hi! Thank you for your answer.

So, I am using Tabularx because my first problem is that the content of the 5th column is wide (longtexts) and after spending hours trying to find a solution in internet, tabularx SEEMED to be the most "okay" one.

In the tabularx documentation, I read that it receives the same inputs as the tabular package. So I don't know what's the special type you're talking about, I know tabular uses l c r for alignment...

I tried to use the booktabs as you said and created a row for example...

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}


\begin{table}  % If I don't nest tabularx inside a table, I get the same errors, nothing changes...
    \begin{tabularx}{\textwidth}{c|c|c|c|c}
        \toprule
        Atributo & Nome & Definição & Obrigatório? & Instruções  \\ % columns ...
        \midrule
        example 1 & example 2 & example 3 &  example 4 &  example 5 \\ 
        \bottomrule
    \end{tabularx} % The error is still pointing to this line...
\end{table}


% This table is from the documentation of "booktabs"
\begin{tabular}{lll}
  \toprule
  Animal & Food  & Size   \\
  \midrule
  dog    & meat  & medium \\
  horse  & hay   & large  \\
  frog   & flies & small  \\
  \bottomrule
\end{tabular}

\end{document}

I get this error:

* Underfull \hbox (badness 10000) in alignment at lines 15--15

My table also gets some | between the columns, dunno why...
Attachments
output
output
Screenshot 2023-06-19 at 21-45-46 testes.png (13.84 KiB) Viewed 5604 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Tabularx - many errors

Post by Stefan Kottwitz »

The | between the columns are there because you have them in the tabularx column definition. The warning about the underfull \hbox is there because you did not fill the row width. Use an X column for the wide and auto-adjusted column, that's a main benefit of tabularx. For example:

Code: Select all

\begin{tabularx}{\textwidth}{ccccX}
Stefan
LaTeX.org admin
Post Reply