Graphics, Figures & TablesWide arrays

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Wide arrays

Post by krislodz »

I have a problem of making wide array fit width of the document, so I used tabularx. But there are now badboxes inside the table.

Here is example of such faulty table:

Code: Select all

\documentclass[draft,10pt]{article}
\usepackage[utf8x]{inputenc}

\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}


\begin{document}

\begin{table}[!htb]
 \centering
 \begin{tabularx}{\textwidth}{|c c|X X X X X X X X X X X X X X X X|}
  \hline
  \multicolumn{2}{|c|}{} & \multicolumn{16}{|c|}{$i=$} \\
  \multicolumn{2}{|c|}{} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12
& 13 & 14 & 15 \\ \hline
  \multirow{3}{*}{$N_w=$} & 4 & 0 & 3 & 2 & 1 & \multicolumn{12}{c|}{} \\
   & 8 & 2 & 1 & 4 & 7 & 6 & 5 & 0 & 3 & \multicolumn{8}{c|}{} \\
   & 16 & 0 & 9 & 2 & 13 & 6 & 11 & 4 & 15 & 10 & 7 & 12 & 3 & 14 & 5 & 8 & 1 \\
  \hline
 \end{tabularx}
 \caption{Word permutation $\pi(i)$ values.}
 \label{tab:ThreefishWordPermutation}
\end{table}

\end{document}
Any ideas in which direction to move?
Last edited by krislodz on Tue May 04, 2010 8:02 pm, edited 1 time in total.

Recommended reading 2024:

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

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

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Wide arrays

Post by localghost »

Code: Select all

\documentclass[draft,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{multirow,tabularx}

\begin{document}
  \begin{table}[!htb]
    \centering
    \setlength{\tabcolsep}{2pt}
    \begin{tabularx}{\textwidth}{|cc|*{16}{X}|}\hline
      & & \multicolumn{16}{|c|}{$i=$} \\
      & & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 \\ \hline
      \multirow{3}{*}{$N_w=$} & 4 & 0 & 3 & 2 & 1 & \multicolumn{12}{c|}{} \\
      & 8 & 2 & 1 & 4 & 7 & 6 & 5 & 0 & 3 & \multicolumn{8}{c|}{} \\
      & 16 & 0 & 9 & 2 & 13 & 6 & 11 & 4 & 15 & 10 & 7 & 12 & 3 & 14 & 5 & 8 & 1 \\ \hline
    \end{tabularx}
    \caption{Word permutation $\pi(i)$ values.}
    \label{tab:ThreefishWordPermutation}
  \end{table}
\end{document}
As soon as the problem is solved, please mark the topic accordingly by editing your initial post and choosing the green checkmark from the icon list.


Best regards
Thorsten
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Re: Wide arrays

Post by krislodz »

Nice, is there a way to make a separation between the second and third row, because third row is too close to vertical line. So the solution was to add column separation ?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Wide arrays

Post by localghost »

Clarify whether we are talking about rows or columns.
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Re: Wide arrays

Post by krislodz »

Sorry, my mistake, columns of course.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Wide arrays

Post by localghost »

Just insert some horizontal space between the concerned columns in the head of tabular environment. But you may have to readjust the length \tabcolsep in order not to run into an overfull box problem again. Finally the horizontal space for the table is limited to the text width.
krislodz
Posts: 42
Joined: Sun Nov 08, 2009 1:13 pm

Re: Wide arrays

Post by krislodz »

Thanks, works fine and table looks better.
Post Reply