1

I need some help regarding formatting a table in tabularx (I'm only allowed to use tabularx). I'm encountering some problems and I can't diagnose the issue as this is the first time I am using Latex.

This is the code which I written so far:

\documentclass{article}

\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}

\begin{table}[htbp]
\centering
\caption{This is a table}
\begin{tabularx}{\textwidth}{|X|c|c|c|c|c|c|c|c|} \hline

\multirow{2}{*}{xxxxxx} & \multirow{2}{*}{xxxxxx} & \multicolumn{2}{c|}    {xxxxx xxxx} & \multicolumn{5}{c|}{xxxxxxxxxx}     \\ \cline{3-9}

 &  & xxxxxxxx  & xxxxxxxxxxx   & xxxxxxxx & xxxxx  & xxxxxxxxx & \multicolumn{2}{c|}{xxxxx} \\ \hline

xxxxxxx et al. (1900) & xxxxx & \multicolumn{2}{c|}{xxxxxx} & xxxxxxxxx & xxxxxx & xxx & $\thicksim$x km & for x = 0.1 \\ \cline{8-9}

& & & & & & & $\thicksim$y km & for x = 0.2 \\ \cline{8-9}

& & & & & & & $\thicksim$z km & for x = 0.3 \\ \cline{8-9}

\end{tabularx}
\end{table}
\end{document}

I got the result as shown below (the first 2 rows are headers):

enter image description here

The problems I faced for this table were:

1) How do I remove the blank spaces along the columns which are not affected by the cline function?

2) The first column contains a citation. How can I make the author's name wrap within the cell? This is circled in blue

3) For the cells circled in red, how can I shift them up, so that they are just below the ~x km for x = 0.1 row?

4) How can I get rid of the | vertical separators between the third and fourth columns after the top 2 header rows??

Thank you all in advance.

Regards Corse

  • welcome to tex.sx, It really helps if you post examples that people can tun to see the problem and test answers, \begin{document} \usepackage{tabularx} \usepackage{multirow} would generate an error. (I fixed it this time:-) – David Carlisle Sep 28 '15 at 8:37
  • You have specified all the columns except the first as c which does not allow linebreaking, then put so many x in each cell that the table is wider than text width and tabularx can do nothing about that. So you need to restructure your table, or use a smaller font, or allow line breaking, but without real text it is a bit hard to suggest the best places to allow line breaks. – David Carlisle Sep 28 '15 at 8:40
  • If you run the complete document as shown in the edited question you do not get any breaks in the vertical lines. If you do, then please edit the question to add whatever non-standard definitions you have that are causing that, otherwise it is not possible to tell you how to avoid those gaps. – David Carlisle Sep 28 '15 at 8:43
  • @David Thanks for the reply. In fact I counted the number x such that they correspond to the original length of characters. In that case, should I convert all the c to x? – Corse Sep 28 '15 at 8:43
  • @David what does it mean by a non-standard definition? – Corse Sep 28 '15 at 8:44
1

You have to make your data fit in the space, tabularx isn't really going to help with that, so I used a normal tabular (you could use tabularx and just not use its features but that just slows things down)

as xxxxxx is never going to automatically hyphenate I added hyphenation points by hand (\-) (and changed a few x to other random letters so I could see which entry was which). This still has a couple of slightly over-full entries, but more or less fits. in the page.

enter image description here

\documentclass{article}

\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}


\noindent X\dotfill X

\begin{table}[htbp]
\centering
\small
\caption{This is a table}
\begin{tabular}{|
*{10}{>{\raggedright\arraybackslash}p{.9cm}|}
} \hline

xx\-xxxx &
xxx\-xxx &
\multicolumn{2}{>{\centering}p{2cm}|}{xxxxx xxxx} & 
\multicolumn{5}{c|}{xxxxxxxxxx}     \\ \cline{3-9}

 &  & xxa\-xxx\-xx  & xxxq\-xxxx\-xxx   & xxxw\-xxxx & xxxxx  & xxxk\-xxxxx & \multicolumn{2}{c|}{xxxxx} \\ \hline

xxx\-xxxx et al. (1900) & xxxxx &
\multicolumn{2}{c|}{xxxxxx} & xxy\-xxx\-xxx & xxxxxx & xxx & $\thicksim$x km & for x = 0.1 \\ \cline{8-9}

& & & & & & & $\thicksim$y km & for x = 0.2 \\ \cline{8-9}

& & & & & & & $\thicksim$z km & for x = 0.3 \\ \cline{8-9}

\end{tabular}
\end{table}
\end{document}

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.