1

I have this table below and I have been ever since trying to make the column work, but it just does not appear like this at all. enter image description here

The first and the second column are fine, but when it comes to the fact that the 3rd and the 4th column splits into 4 sub columns gives a hard time.

  • I noticed that you've set the tag "tabularx". Are you looking to use that particular environment, instead of (say) a "tabular" environment? – Mico Sep 23 '15 at 11:34
  • Sorry my mistake. It was suppose to be tabular. Thanks! – shahrina ismail Sep 23 '15 at 13:41
1

I think you need to contemplate displaying your table in landscape mode, especially if you want to avoid having to resort to minuscule font sizes. In the code below, I use \allowbreak directives to introduce line breaks in some of the columns. I would also like to recommend (i) not using any vertical lines in the table and (ii) using the line-drawing macros of the booktabs package instead of \hline and \cline.

enter image description here

\documentclass[a4paper]{article}  % specify page size
\usepackage[margin=1in]{geometry} % specify text block size
\usepackage{rotating,tabularx,amssymb,ragged2e,booktabs}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\swb{{\scriptstyle\Box}} % "small white box"
\begin{document}

\begin{sidewaystable}
\setlength\tabcolsep{2pt} % default value: 6pt
\begin{tabularx}{\textwidth}{@{}*{10}{C}@{}} 
\toprule
 $\delta_m$ & $2 \neq \swb$ & \multicolumn{4}{c}{$5 \cdot 29 \neq \swb$} & \multicolumn{4}{c}{$13 \cdot 1789 \neq \swb$} \\
\cmidrule(lr){3-6} \cmidrule(l){7-10}
    &   & $5=\swb$ & $29\neq\swb$ & $5\neq\swb$ & $29=\swb$ & $13=\swb$ & $1789\neq\swb$ & $13\neq\swb$ & $1789=\swb$ \\
\midrule
Primes that satisfy the condition $\delta_m \neq \swb$  & 
$q\equiv\pm3\pmod8$ & 
$q\equiv\pm1\pmod5$ & 
$q\equiv 2,3,8,10,\allowbreak11,12,14,15,\allowbreak17,18,19,21,\allowbreak26,27\pmod{29}$ & 
$q\equiv\pm2\pmod5$ & 
$q\equiv 1,4,5,6,\allowbreak7,9,13,16,20,\allowbreak22,23,24,25,\allowbreak28\pmod{29}$ & 
$q\equiv 1,3,4,9,\allowbreak10,12\pmod{13}$ & 
$q\equiv A\pmod{1789}$ & 
$q\equiv2,5,6,7,\allowbreak8,11\pmod{13}$ & 
$q\equiv B\pmod{1789}$ \\ 
\midrule
 Period of $w_n$  & $24$ & $30$ & $102$ & $30$ & $102$ & $30$ & $2670$ & $30$ & $2670$ \\
\bottomrule
\end{tabularx}
\end{sidewaystable}
\end{document}
2

It is the reverse actually: you should not split one column in to four columns, Use four columns and merge them in to one.

\documentclass[border=3pt]{standalone}
\begin{document}
\begin{tabular}{|*{10}{l|}} \hline
  1 & 2 & \multicolumn{4}{c|}{3 to 6} & \multicolumn{4}{c|}{7 to 10} \\\cline{3-10}
    &   & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
  1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
\end{tabular}
\end{document}

enter image description here

You can use tabularx as stated in comments below:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{tabularx,array}
\begin{document}
\begin{landscape}
\begin{table}[htbp]
\begin{tabularx}{\textwidth}{|*{10}{X|}} \hline
  1 & 2 & \multicolumn{4}{c|}{3 to 6} & \multicolumn{4}{c|}{7 to 10} \\\cline{3-10}
    &   & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
  1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
\end{tabularx}
\end{table}
\end{landscape}
\end{document}
  • Thank you so much @Harish this is exactly what I needed. Thank you for explaining the reverse part as well. – shahrina ismail Sep 23 '15 at 13:15
  • i was wondering how if I want all the 10 columns to have same width? probably like 1.7cm width for each column. because at the moment some columns are wider than the other. – shahrina ismail Sep 24 '15 at 2:15
  • @Sharina Use p{1.7cm} instead of c column types. If you want the table to span \texwidth, use \usepackage{tabularx} and then \begin{tabularx}{\textwidth}{|*{10}{X|} – user11232 Sep 24 '15 at 2:21
  • This is what I did : \begin{landscape} \begin{table}[htbp] \begin{center} \begin{tabularx}{\textwidth}{|*{10}{X|} \hline 1 & 2 & \multicolumn{4}{ p{1.7cm} |}{3 to 6} & \multicolumn{4}{ p{1.7cm} |}{7 to 10} \\\cline{3-10} & & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline \end{tabularx} \end{center} \end{table} \end{landscape} But it gave runaway argument. – shahrina ismail Sep 24 '15 at 3:10
  • @Sharina Please see the edit. – user11232 Sep 24 '15 at 3:26

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.