2

When I use multicolumn and multirow together in a table, text does not wrap within the multicolumn, and the column size is automatically taken to be very long. Code with problem is attached:

\begin{table}[htbp]
\centering
%  \resizebox{\textwidth}{!}{%
  \begin{tabular}{| C{2cm} | C{2cm} | C{2cm} |}  \hline
  \multirow{2}{4em} {Crack length(a)} & \multicolumn{2}{c}{Geometric (and loading) parameter in SIF}\\\cline{2-3}
  & Present & From ~\cite{RC2}\\\hline
0.200 & 1.297 & 1.313 \\\hline
0.300 & 1.426 & 1.431 \\\hline
0.400 & 1.565 & 1.567 \\\hline
 \end{tabular}

How do I make the column size fixed and wrap the text within it? If the multicolumn text needs 2 rows, that is also fine. But how to nest multirows and multicolumn?

2
  • Welcome to TeX SX! Which size – cell width?
    – Bernard
    Commented Jun 13, 2017 at 18:43
  • 2
    I see, but your code is not compilable. Please post a full code, staring with \documentclass and ending in \end{document}. In particular, what is the C column type?
    – Bernard
    Commented Jun 13, 2017 at 18:49

2 Answers 2

2

Does something like the following meet your objectives?

enter image description here

\documentclass{article}
\usepackage{array} % no need for 'multirow' package, really
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % is this right?
\begin{document}

\begin{table}[htbp]
\setlength\extrarowheight{2pt} % for a more "open" look
\centering
 \begin{tabular}{| C{2cm} | C{2cm} | C{2cm} |}  
 \hline
 Crack length (a) & 
 \multicolumn{2}{C{\dimexpr4cm+2\tabcolsep\relax}|}{Geometric (and loading) parameter in SIF}\\
 \cline{2-3}
       & Present & From \cite{RC2}\\\hline
 0.200 & 1.297   & 1.313 \\\hline
 0.300 & 1.426   & 1.431 \\\hline
 0.400 & 1.565   & 1.567 \\\hline
\end{tabular}
\end{table}
\end{document}
2
  • Exactly what I wanted. Thank you very much. But can u plz explain, how did u do this without using multirow? And is it possible to change vertical alignment as well within cells? Commented Jun 14, 2017 at 16:08
  • @KoushikSwaminathan - Well, I was simply assuming that automatic line-wrapping should be enabled; that's why I defined the C column type as a centered version of the p column type. With automatic line-wrapping, I simply deleted the \multirow "wrapper" and checked the output; to my taste, the output looks just fine. :-) Separately: There are lots and lots of queries (and answers!) on this site about changing the vertical alignment in cells; do look around and see if you manage to find one ore more postings that address your specific formatting needs.
    – Mico
    Commented Jun 14, 2017 at 17:12
1

I would use simple c columns and manually break the header. The table seems to contain mainly numerical data, so I feel that text wrapping is not a real requirement.

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{table}[htbp]
  \setlength\extrarowheight{2pt} % for a more "open" look
  \centering
    \begin{tabular}{ |*3{c|} }  
      \hline
      Crack length & \multicolumn{2}{c|}{Geometric (and loading)} \\ [-2pt]
      (a)          & \multicolumn{2}{c|}{parameter in SIF}        \\ \cline{2-3}
                   & Present & From~[ref] \\ \hline
      0.200        & 1.297   & 1.313      \\ \hline
      0.300        & 1.426   & 1.431      \\ \hline
      0.400        & 1.565   & 1.567      \\ \hline
  \end{tabular}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .