将大表格适合到页面上

将大表格适合到页面上

我的表格单元格中有长句子,我想将文本换行,以便表格适合页面。目前表格超出了页面宽度。下面是我使用 Excel2LateX 生成的代码

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{llll}
    \toprule
    \multicolumn{1}{c}{\textbf{Strategy}} & \multicolumn{1}{c}{\textbf{Application area/sector}} & \multicolumn{1}{c}{\textbf{Advantages}} & \multicolumn{1}{c}{\textbf{Limitations}} \\
    \midrule
    \midrule
    Enhance energy efficiency and energy conservation & Applied mainly in commercial and industrial buildings & Energy saving from 10\% to 20\% easily achievable. & May involve extensive capital investment for installation of energy saving device. \\
    \midrule
    Increase usage of clean fuels & Substitution of coal by natural gas for power generation. & Natural gas emits 40Ð50\% less CO2 than coal due to its lower carbon content and higher combustion efficiency; cleaner exhaust gas (lower particulates and sulfur dioxide emissions). & Higher fuel cost for conventional natural gas. Comparable cost for shale gas. \\
    \midrule
    Adopt clean coal technologies & Integrated gasification combined cycle (IGCC), pressurized fluidized bed combustor (PFBC) etc. to replace conventional combustion. & Allow the use of coal with lower emissions of air pollutants. & Significant investment needed to roll out technologies widely. \\
    \midrule
    Use of renewable energy & Hydro, solar (thermal), wind power,
and biofuels highly developed. & Use of local natural resources; no or low greenhouse and toxic gas emissions. & Applicability may depend on local resources availability and cost. Power from solar, wind, marine etc. are intermittent and associated technologies are not mature; most current renewable energies are more costly than conventional energy. \\
    \midrule
    Development of nuclear power & Nuclear fission adopted mainly in US, France, Japan, Russia and China. Nuclear fusion still in research and development phase. & No air pollutant and greenhouse gas emissions. & Usage is controversial; development of world's nuclear power is hindered due to the Fukushima Nuclear Accident in 2011, e.g. Germany will phase out all its nuclear power by 2022. \\
    \midrule
    Afforestation and reforestation & Applicable to all countries & Simple approach to create natural and sustainable CO2 sinks. & Restricts/prevents land use for other applications \\
    \midrule
    Carbon capture and storage & Applicable to large CO2 point emission sources. & It can reduce vast amount of CO2 with capture efficiency 480\%. & CCS full chain technologies not proven at full commercial scale \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

答案1

对于这样的表格,您不应该使用l-column 类型。而p{<width>}应该使用定义指定宽度的列的类型:

\documentclass[]{article}

\usepackage[margin=2.5cm]{geometry}

\usepackage{booktabs}

\begin{document}

\newdimen\allcolwidth
\allcolwidth=\dimexpr\textwidth-8\tabcolsep\relax% this sets a width which is as wide as possible with 4 columns in a table

\begin{table}[htbp]
  \centering
  \caption{Add caption}
  \begin{tabular}{p{0.15\allcolwidth}p{0.25\allcolwidth}p{0.25\allcolwidth}p{0.35\allcolwidth}}
    \toprule
    \multicolumn{1}{c}{\textbf{Strategy}} &
    \multicolumn{1}{p{0.25\allcolwidth}}{\centering\textbf{Application area/sector}} & \multicolumn{1}{c}{\textbf{Advantages}} & \multicolumn{1}{c}{\textbf{Limitations}} \\
    \midrule
    \midrule
    Enhance energy efficiency and energy conservation & Applied mainly in commercial and industrial buildings & Energy saving from 10\% to 20\% easily achievable. & May involve extensive capital investment for installation of energy saving device. \\
    \midrule
    Increase usage of clean fuels & Substitution of coal by natural gas for power generation. & Natural gas emits 40Ð50\% less CO2 than coal due to its lower carbon content and higher combustion efficiency; cleaner exhaust gas (lower particulates and sulfur dioxide emissions). & Higher fuel cost for conventional natural gas. Comparable cost for shale gas. \\
    \midrule
    Adopt clean coal technologies & Integrated gasification combined cycle (IGCC), pressurized fluidized bed combustor (PFBC) etc. to replace conventional combustion. & Allow the use of coal with lower emissions of air pollutants. & Significant investment needed to roll out technologies widely. \\
    \midrule
    Use of renewable energy & Hydro, solar (thermal), wind power,
and biofuels highly developed. & Use of local natural resources; no or low greenhouse and toxic gas emissions. & Applicability may depend on local resources availability and cost. Power from solar, wind, marine etc. are intermittent and associated technologies are not mature; most current renewable energies are more costly than conventional energy. \\
    \midrule
    Development of nuclear power & Nuclear fission adopted mainly in US, France, Japan, Russia and China. Nuclear fusion still in research and development phase. & No air pollutant and greenhouse gas emissions. & Usage is controversial; development of world's nuclear power is hindered due to the Fukushima Nuclear Accident in 2011, e.g. Germany will phase out all its nuclear power by 2022. \\
    \midrule
    Afforestation and reforestation & Applicable to all countries & Simple approach to create natural and sustainable CO2 sinks. & Restricts/prevents land use for other applications \\
    \midrule
    Carbon capture and storage & Applicable to large CO2 point emission sources. & It can reduce vast amount of CO2 with capture efficiency 480\%. & CCS full chain technologies not proven at full commercial scale \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
\end{document}

在此处输入图片描述

对于这么宽的表格,您不妨插入一个sidewaystable(由-package 提供rotating):

\documentclass[]{article}

\usepackage[margin=2.5cm]{geometry}

\usepackage{booktabs}
\usepackage{rotating}

\newdimen\allcolwidth

\begin{document}
\begin{sidewaystable}
  \allcolwidth=\dimexpr\textwidth-8\tabcolsep\relax%this sets a width which is as possible with 4 columns
  \centering
  \caption{Add caption}
  \begin{tabular}{p{0.15\allcolwidth}p{0.25\allcolwidth}p{0.25\allcolwidth}p{0.35\allcolwidth}}
    \toprule
    \multicolumn{1}{c}{\textbf{Strategy}} &
    \multicolumn{1}{p{0.25\allcolwidth}}{\centering\textbf{Application area/sector}} & \multicolumn{1}{c}{\textbf{Advantages}} & \multicolumn{1}{c}{\textbf{Limitations}} \\
    \midrule
    \midrule
    Enhance energy efficiency and energy conservation & Applied mainly in commercial and industrial buildings & Energy saving from 10\% to 20\% easily achievable. & May involve extensive capital investment for installation of energy saving device. \\
    \midrule
    Increase usage of clean fuels & Substitution of coal by natural gas for power generation. & Natural gas emits 40Ð50\% less CO2 than coal due to its lower carbon content and higher combustion efficiency; cleaner exhaust gas (lower particulates and sulfur dioxide emissions). & Higher fuel cost for conventional natural gas. Comparable cost for shale gas. \\
    \midrule
    Adopt clean coal technologies & Integrated gasification combined cycle (IGCC), pressurized fluidized bed combustor (PFBC) etc. to replace conventional combustion. & Allow the use of coal with lower emissions of air pollutants. & Significant investment needed to roll out technologies widely. \\
    \midrule
    Use of renewable energy & Hydro, solar (thermal), wind power,
and biofuels highly developed. & Use of local natural resources; no or low greenhouse and toxic gas emissions. & Applicability may depend on local resources availability and cost. Power from solar, wind, marine etc. are intermittent and associated technologies are not mature; most current renewable energies are more costly than conventional energy. \\
    \midrule
    Development of nuclear power & Nuclear fission adopted mainly in US, France, Japan, Russia and China. Nuclear fusion still in research and development phase. & No air pollutant and greenhouse gas emissions. & Usage is controversial; development of world's nuclear power is hindered due to the Fukushima Nuclear Accident in 2011, e.g. Germany will phase out all its nuclear power by 2022. \\
    \midrule
    Afforestation and reforestation & Applicable to all countries & Simple approach to create natural and sustainable CO2 sinks. & Restricts/prevents land use for other applications \\
    \midrule
    Carbon capture and storage & Applicable to large CO2 point emission sources. & It can reduce vast amount of CO2 with capture efficiency 480\%. & CCS full chain technologies not proven at full commercial scale \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel2}%
\end{sidewaystable}
\end{document}

在此处输入图片描述

答案2

使用\makecelltabularx作为表格,ragged2e以及\small字体大小以便更好地在单元格中对齐文本并减小\tabcolsep尺寸可得到:

在此处输入图片描述

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{booktabs, makecell, tabularx}
    \renewcommand\theadfont{\bfseries\normalsize}
\usepackage{ragged2e}
\usepackage{siunitx}

\begin{document}
    \begin{table}[htbp]
\centering
    \caption{Add caption}
\label{tab:addlabel}%
    \setlength\tabcolsep{3pt}
    \small
    \begin{tabularx}{\linewidth}{@{}>{\hsize=0.7\hsize\RaggedRight}X
                             *{3}{>{\hsize=1.1\hsize\RaggedRight}X}
                              @{}}
    \toprule
\thead[b]{Strategy} 
    &   \thead[b]{Application\\ area/sector}
        &   \thead[b]{Advantages}
            & \thead[b]{Limitations}                \\
    \midrule
Enhance energy efficiency and energy conservation
    &   Applied mainly in commercial and industrial buildings 
        &   Energy saving from \SIrange{10}{20}{\%} easily achievable. 
            &   May involve extensive capital investment for installation of energy saving device. \\
    \midrule
Increase usage of clean fuels 
    &   Substitution of coal by natural gas for power generation. 
        &   Natural gas emits \SIrange{10}{20}{\%} less CO2 than coal due to its lower carbon content and higher combustion efficiency; cleaner exhaust gas (lower particulates and sulfur dioxide emissions). 
            &   Higher fuel cost for conventional natural gas. Comparable cost for shale gas.      \\
    \midrule
Adopt clean coal technologies 
    &   Integrated gasification combined cycle (IGCC), pressurized fluidized bed combustor (PFBC) etc. to replace conventional combustion. 
        &   Allow the use of coal with lower emissions of air pollutants. 
            &   Significant investment needed to roll out technologies widely. \\
    \midrule
Use of renewable energy 
    &   Hydro, solar (thermal), wind power,
and biofuels highly developed. 
        &   Use of local natural resources; no or low greenhouse and toxic gas emissions. 
            &   Applicability may depend on local resources availability and cost. Power from solar, wind, marine etc. are intermittent and associated technologies are not mature; most current renewable energies are more costly than conventional energy. \\
    \midrule
Development of nuclear power 
    &   Nuclear fission adopted mainly in US, France, Japan, Russia and China. Nuclear fusion still in research and development phase. 
        &   No air pollutant and greenhouse gas emissions. 
            &   Usage is controversial; development of world's nuclear power is hindered due to the Fukushima Nuclear Accident in 2011, e.g. Germany will phase out all its nuclear power by 2022. \\
    \midrule
Afforestation and reforestation 
    &   Applicable to all countries 
        &   Simple approach to create natural and sustainable CO2 sinks. 
            &   Restricts/prevents land use for other applications \\
    \midrule
Carbon capture and storage 
    &   Applicable to large CO2 point emission sources. 
        &   It can reduce vast amount of CO2 with capture efficiency \SI{480}{\%}. 
            &   CCS full chain technologies not proven at full commercial scale \\
    \bottomrule
    \end{tabularx}%
\end{table}%
\end{document}

相关内容