3

My table got our-of-border once I merged cells.

How can I wrap the text in the merged cells?

My Code

    \documentclass[a4paper]{article}
\usepackage{booktabs,tabularx,multirow}

\begin{document}
    
    \begin{table}[]
        \centering
        \begin{tabularx}{\textwidth}{@{} p{0.12\textwidth}p{0.28\textwidth}p{0.28\textwidth}p{0.28\textwidth} @{}}
            \toprule
            &
            Mitigation strategy &
            \multicolumn{1}{l|}{Adaptation strategy} &
            \\ \midrule
            Approach &
            Actions taken to reduce   emissions that cause climate change &
            \multicolumn{2}{l|}{Adaptations made to operations   to manage the impact of climate change} \\ \midrule
            Focus &
            Addressing underlying cause of   climate change &
            \multicolumn{2}{l|}{Managing the risks and   vulnerabilities due to exposure to climate change} \\ \midrule
            \begin{tabular}[c]{@{}l@{}}Sub--\\ strategies\end{tabular} &
            N/A &
            \multicolumn{1}{l|}{Soft adaptation: Refining existing processes and operations; incremental approach} &
            Hard adaptation: Investing in new technology, infrastructure, and (re)location; transformational approach \\ \midrule
            \begin{tabular}[c]{@{}l@{}}Time\\ horizon\end{tabular} &
            Long-term &
            \multicolumn{1}{l|}{Short-term} &
            Medium-term \\ \midrule
            Scale &
            Global &
            \multicolumn{2}{l|}{More local} \\ \midrule
            \begin{tabular}[c]{@{}l@{}}Financial \\ investment\end{tabular} &
            Medium-high &
            \multicolumn{1}{l|}{Low-medium} &
            Medium-high \\ \midrule
            \begin{tabular}[c]{@{}l@{}}Aviation\\ industry\\ examples\end{tabular} &
            Galápagos Ecological Airport designed to run completely on renewable energies (65\% from wind, 35\% from solar), and using 80\% recycled materials in its construction and re-use of wastewater in its system (estimated costs \$40 million) &
            \multicolumn{1}{l|}{Changi Airport resurfacing Runway 1 with stronger and more durable asphalt with higher temperature resistance due to climate change (estimated cost \$50 million)} &
            Plans to build a new 10-mile long sea wall at San Francisco International Airport to guard against 3 feet of sea level rise plus 2 more feet for storms/waves (estimated cost \$587 million) \\ \bottomrule
        \end{tabularx}
    \end{table}
\end{document}

Output

enter image description here

Original Table enter image description here

5
  • Don't use the l column type if you want line breaking. Use p Commented May 14, 2023 at 6:14
  • I am using p column types.
    – OOzy Pal
    Commented May 14, 2023 at 7:28
  • 2
    Not in the multicolumn cells Commented May 14, 2023 at 7:33
  • You can use tabularray.
    – Clara
    Commented May 14, 2023 at 7:34
  • 1
    you need an X column in any tabularx and your multicolm also need X or p as l entries are single line. Commented May 14, 2023 at 8:31

2 Answers 2

2

Like this:

enter image description here

Table code is quite simpler and concise, if you use tabularray package, ragged2e package for formatting text in cells and booktabs and siunitx for table rules and consistent writing quantities percentages:

\documentclass[a4paper]{article}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
    \begin{table}[ht]
        \centering
\begin{tblr}{colsep=3pt,
             colspec = {X[l, m] | X[1.5, cmd=\RaggedRight]  
                                | X[1.5, cmd=\RaggedRight] 
                                | X[1.5, cmd=\RaggedRight]  @{}},
             hspan = minimal}
        \toprule
    &   Mitigation strategy   
        &   \SetCell[c=2]{c}    Adaptation strategy  
            &       \\ 
        \midrule
Approach    
    & Actions taken to reduce  emissions that cause climate change 
        &   \SetCell[c=2]{j}    Adaptations made to operations to manage the impact of climate change   \\ \midrule
Focus 
    & Addressing underlying cause of   climate change 
        &   \SetCell[c=2]{j}    Managing the risks and vulnerabilities due to exposure to climate change \\ \midrule
Sub-strategies
    & N/A 
        &   Soft adaptation: Refining existing processes and operations; incremental approach
            &   Hard adaptation: Investing in new technology, infrastructure, and (re)location; transformational approach                                                                   \\
        \midrule
Time horizon
    &   Long-term 
        &   {Short-term} 
            &   Medium-term                                                                             \\ 
        \midrule
Scale 
    &   Global
        &   \SetCell[c=2]{j}    More local                                                              \\ 
        \midrule
Financial investment
    &   Medium-high 
        &   Low-medium
            &   Medium-high                                                                             \\
    \midrule
Aviation industry examples
    &   Galápagos Ecological Airport designed to run completely on renewable energies (\qty{65}{\%} from wind, \qty{35}{\%} from solar), and using \qty{80}{\%} recycled materials in its construction and re-use of waste water in its system (estimated costs \$40 million) 
        &   Changi Airport resurfacing Runway 1 with stronger and more durable asphalt with higher temperature resistance due to climate change (estimated cost \$50 million) 
            &   Plans to build a new 10-mile long sea wall at San Francisco International Airport to guard against 3 feet of sea level rise plus 2 more feet for storms/waves (estimated cost \$587 million \\ 
        \bottomrule
\end{tblr}
    \end{table}
\end{document}

tabularray has a bit different syntax for writing multi column cells: SetCell[c=<num. of columns>]{j}. For details consult package documentation.

Edit:
Corrected column header for last two columns.

2
  • Thank you. I had to add \SetCell[c=2]{j} Adaptation strategy as the Adaptation strategy header is merged with the cell next to it.
    – OOzy Pal
    Commented May 14, 2023 at 8:02
  • I try to replicate showed table image.
    – Zarko
    Commented May 14, 2023 at 8:34
2

Just for completeness (since the OP employed a tabularx environment), here's a tabularx-based solution.

enter image description here

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{booktabs,tabularx,ragged2e}
\newcolumntype{P}{p{\dimexpr0.51\textwidth+2\tabcolsep\relax}@{}}
  % 0.51=2*0.255
\begin{document}

\begin{table}[tbp]
\setlength\tabcolsep{3pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} 
     >{\raggedright}X 
     *{3}{>{\RaggedRight}p{0.255\textwidth}} 
     @{}}
   \toprule
   &
   Mitigation strategy &
   \multicolumn{2}{c@{}}{Adaptation strategy} \\ 
   \midrule
   Approach &
   Actions taken to reduce emissions that cause climate change &
   \multicolumn{2}{P}{Adaptations made to operations to manage the impact of climate change} \\ 
   \midrule
   Focus &
   Address underlying cause of climate change &
   \multicolumn{2}{P}{Manage the risks and vulnerabilities due to exposure to climate change} \\ 
   
   & & \multicolumn{2}{c@{}}{Adaptation Substrategies} \\
   \cmidrule(l){3-4}
   & &
   Soft adaptation: Refine existing processes and operations; incremental approach &
   Hard adaptation: Invest in new technology, infrastructure, and (re)location; transformational approach\\ 
   \midrule
   
   \addlinespace[3ex]
   Time horizon & Long-term & Short-term & Medium-term \\ 
   \midrule
   Scale & Global & More local \\ 
   \midrule
   Financial investment 
   & Medium--high & Low--medium & Medium--high \\ 
   \midrule
   Aviation industry examples &
   Galápagos Ecological Airport designed to run completely on renewable energies (65\% from wind, 35\% from solar), and using 80\% recycled materials in its construction and re-use of wastewater in its system. 
   
   Estimated cost: \$40~million &
   Changi Airport resurfacing Runway~1 with stronger and more durable asphalt with higher temperature resistance due to climate change. 
   
   Estimated cost: \$50~million &
   Plans to build a new 10-mile long sea wall at San Francisco International Airport to guard against 3~feet of sea level rise plus 2 more feet for storms\slash waves. 
   
   Estimated cost: \$587 million \\ 
   \bottomrule
\end{tabularx}
\end{table}
\end{document}

You must log in to answer this question.

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