3

I am trying to simply wrap the text centered across two columns. The text is long so wrapping is needed. However, the result truncates the text.

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{tabular} { |p{0.50\textwidth} |p{0.50\textwidth} |}
\hline
\multicolumn{2} {|c|} 
{Number and Percent of Selected Cardiovascular Events by Treatment Group
 and Hazard Ratio From Cox Regression Analysis}\\
\hline
Data Information 1 & Data Information 2\\
\hline
\end{tabular}
\end{document}
5

You seem to be after a 2-column tabular where each column occupies 50% of the \textwidth. In these instances it's sometimes easier to use tabularx's X-column to spread things evenly. The calculation for the \multicolumn removes the column padding and rule width to ensure the paragraph content fits within the remainder of \textwidth after those lengths are removed:

enter image description here

\documentclass{article}

\usepackage{tabularx}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{ | X | X | }
  \hline
  \multicolumn{2} { | p{\dimexpr \textwidth-2\tabcolsep-2\arrayrulewidth} | }{%
    Number and Percent of Selected Cardiovascular Events by Treatment Group
    and Hazard Ratio From Cox Regression Analysis} \\
  \hline
  Data Information 1 & Data Information 2 \\
  \hline
\end{tabularx}

\end{document}
4

The column width calculations are a little more complicate:

  • By default, the space \tabcolsep is added at the left and right side of a column.

  • The rules have width \arrayrulewidth. The width contributes to the table width if package array is loaded.

  • The column width for \multicolumn can also be calculated and column type p can be used.

Full example that shows the calculations if package array is loaded.

\documentclass{article}
\usepackage{array}

\begin{document}
\noindent
\begin{tabular} {
  |p{.5\dimexpr\linewidth-4\tabcolsep-3\arrayrulewidth\relax}
  |p{.5\dimexpr\linewidth-4\tabcolsep-3\arrayrulewidth\relax} |}
\hline
\multicolumn{2} {|>{\centering}p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}
{Number and Percent of Selected Cardiovascular Events by Treatment Group
 and Hazard Ratio From Cox Regression Analysis}\\
\hline
Data Information 1 & Data Information 2\\
\hline
\end{tabular}
\end{document}

Result

Further reading:

  • Thank you. That works! I will need to study it a little to understand it. – gag Sep 5 '17 at 20:05

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.