表格列宽格式错误

表格列宽格式错误

如何将此表中的两列设置为固定宽度?我想在单词“使用 Ralstonia eutropha 进行生物合成”之间添加换行符,但使用 \newline 无法实现。与文档的其余部分相比,表格中的文本字体也较小,但我希望表格更长,必要时可以跨越两页。

\documentclass[11pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath, amsfonts, amssymb}
\begin{document}
\begin{table}[H]
\centering
\hrule
\vspace{1mm}
\caption{Summary of the advantages and disadvantages of each method of ethanol production}
\vspace{1mm}
\hrule
\vspace{2mm}
\begin{adjustbox}{max width=\textwidth,center}
\begin{tabular}[t]{l*{1}{>{\raggedright\arraybackslash}p{\linewidth}}}
Ethene Hydration&
\textbf{Advantages:}
\vspace{2mm}
\newline
1) Cost effective as ethene is a product of the petroleum industry so can be produced cheaply
\vspace{2mm}
\newline
2) Ethanol produced as a continuous process unlike fermentation which occurs under batch conditions
\vspace{2mm}
\newline
\textbf{Disadvantages:}
\vspace{2mm}
\newline
1) Optimal operating conditions require high temperatures and pressures to be maintained
\vspace{2mm}
\newline
2) Ethene is derived from crude oil which is a non-renewable resource meaning ethanol produced by this method has a high carbon footprint
\vspace{2mm}
\\
Fermentation&
\textbf{Advantages:}
\vspace{2mm}
\newline
1) Ethanol produced by this method is relatively cheap as energy requirements and cost of raw materials is low
\vspace{2mm}
\newline
2) Ethanol has a low carbon footprint due to renewable source of raw materials
\vspace{2mm}
\newline
\textbf{Disadvantages:}
\vspace{2mm}
\newline
1) Reaction is relatively slow since ethanol is toxic to yeast in high concentrations
\vspace{2mm}
\newline
2) Production takes place under batch conditions further making production by fermentation slow
\vspace{2mm}
\newline
3) Biomass growth for Ethanol production uses land which would otherwise be used for food generation
\vspace{2mm}
\\
Biosynthesis using Ralstonia eutropha&
\textbf{Advantages:}
\vspace{2mm}
\newline
1) Low to negative carbon footprint
\vspace{2mm}
\newline
2) Vaporization off waste streams providing economic incentive to carbon capture
\vspace{2mm}
\newline
3) Ability to implement continuous production process
\vspace{2mm}
\newline
4) Compatibility with renewable energy sources
\vspace{2mm}
\newline
\textbf{Disadvantages:}
\vspace{2mm}
\newline
1) Currently very low ethanol yields
\vspace{2mm}
\newline
2) Expensive due to the low efficiencies of MES leading to high costs of acetate production. \cite{choi_factors_1999} indicate the substrate cost can be up to 38\% of the operating cost
\vspace{2mm}
\\
\bottomrule
\end{tabular}
\end{adjustbox}
\label{tab:ethanol_production}
\end{table}
\end{document}

在此处输入图片描述

下图显示了我希望的表格外观(在 Microsoft Word 中完成)。

在此处输入图片描述

答案1

让我们逐一讨论这些问题:

  • 要在第一列较长的文本内换行,您可以使用p类型列,就像您用于第二列的列一样。选择合适的宽度,您就不必担心手动换行。

  • 由于您过去常常将过宽的表格挤入文本宽度,因此表格中的字体大小小于文档其余部分中的字体大小adjustbox。删除调整框,然后自行选择合适的列宽,或者让适当的程序包为您计算(tabularx适用于单页表格,xltabular适用于多页表格)。

  • 要使表格跨越多页,请删除环境tabletabularlongtable或替换xltabular(在序言中加载相应的包)并将\caption和移动到/\label内。对于这个特定的表格,我选择这样做是因为我不想担心计算第二列所需的宽度,同时确保表格不超过可用的文本宽度。longtablexltabularxltabular

我在示例中尝试解决的一些其他问题:

  • 我使用了一个定制的enumerate列表(在包的帮助下完成enumitem)以便克服手动编号项目的需要。
  • 我删除了所有手动\vspace命令。如果您希望表格各行之间有更多空间,可以相应地调整环境设置tabenum

这导致了以下 MWE,其中我还添加了一种基于enumerate/ 的替代itemize方法:

\documentclass[11pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath, amsfonts, amssymb}
\usepackage{xltabular,booktabs}
\setlength{\LTcapwidth}{\textwidth}
\usepackage{enumitem}
\newlist{tabenum}{enumerate}{1}
\setlist[tabenum]{label*=\arabic*),
                  leftmargin=*,
                  nosep}



%%%%% only used in the second example %%%%%
\usepackage{pifont}
\newlist{pros}{itemize}{1}
\setlist[pros]{label*=\ding{52},
                  leftmargin=*,
                  nosep}
                  
\newlist{cons}{itemize}{1}
\setlist[cons]{label*=\ding{56},
                  leftmargin=*,
                  nosep}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      

\begin{document}
\begin{xltabular}{\linewidth}{@{}>{\raggedright\arraybackslash}p{2.75cm}X@{}}
\caption{Summary of the advantages and disadvantages of each method of ethanol production}
\label{tab:ethanol_production}\\
\toprule
Ethene Hydration&
\textbf{Advantages:}
\begin{tabenum}
  \item Cost effective as ethene is a product of the petroleum industry so can be produced cheaply
  \item Ethanol produced as a continuous process unlike fermentation which occurs under batch conditions
\end{tabenum}

\textbf{Disadvantages:}
\begin{tabenum}
  \item Optimal operating conditions require high temperatures and pressures to be maintained
  \item Ethene is derived from crude oil which is a non-renewable resource meaning ethanol produced by this method has a high carbon footprint
\end{tabenum}
\\
Fermentation&
\textbf{Advantages:}
\begin{tabenum}
  \item Ethanol produced by this method is relatively cheap as energy requirements and cost of raw materials is low
  \item Ethanol has a low carbon footprint due to renewable source of raw materials
\end{tabenum}

\textbf{Disadvantages:}
\begin{tabenum}
  \item Reaction is relatively slow since ethanol is toxic to yeast in high concentrations
  \item Production takes place under batch conditions further making production by fermentation slow
  \item Biomass growth for Ethanol production uses land which would otherwise be used for food generation
\end{tabenum}
\\
Biosynthesis using Ralstonia eutropha&
\textbf{Advantages:}
\begin{tabenum}
  \item Low to negative carbon footprint
  \item Vaporization off waste streams providing economic incentive to carbon capture
  \item Ability to implement continuous production process
  \item Compatibility with renewable energy sources
\end{tabenum}

\textbf{Disadvantages:}
\begin{tabenum}
  \item Currently very low ethanol yields
  \item Expensive due to the low efficiencies of MES leading to high costs of acetate production. \cite{choi_factors_1999} indicate the substrate cost can be up to 38\% of the operating cost
\end{tabenum}
\\
\bottomrule
\end{xltabular}

\newpage

\begin{enumerate}
\item Ethene Hydration
  \begin{pros}
  \item Cost effective as ethene is a product of the petroleum industry so can be produced cheaply
  \item Ethanol produced as a continuous process unlike fermentation which occurs under batch conditions
  \end{pros}
  \begin{cons}
  \item Optimal operating conditions require high temperatures and pressures to be maintained
  \item Ethene is derived from crude oil which is a non-renewable resource meaning ethanol produced by this method has a high carbon footprint
  \end{cons}
\item Fermentation
  \begin{pros}
  \item Ethanol produced by this method is relatively cheap as energy requirements and cost of raw materials is low
  \item Ethanol has a low carbon footprint due to renewable source of raw materials
  \end{pros}
  \begin{cons}
  \item Reaction is relatively slow since ethanol is toxic to yeast in high concentrations
  \item Production takes place under batch conditions further making production by fermentation slow
  \item Biomass growth for Ethanol production uses land which would otherwise be used for food generation
  \end{cons}
\item Biosynthesis using Ralstonia eutropha
  \begin{pros}
  \item Low to negative carbon footprint
  \item Vaporization off waste streams providing economic incentive to carbon capture
  \item Ability to implement continuous production process
  \item Compatibility with renewable energy sources
  \end{pros}
  \begin{cons}
  \item Currently very low ethanol yields
  \item Expensive due to the low efficiencies of MES leading to high costs of acetate production. \cite{choi_factors_1999} indicate the substrate cost can be up to 38\% of the operating cost
  \end{cons}
\end{enumerate}


\end{document}

基于的方法的输出xltabular

在此处输入图片描述

替代方法的输出:

在此处输入图片描述

相关内容