表格中的 \hbox 未满和过满

表格中的 \hbox 未满和过满

我对 Latex 还不是很熟悉,一直在使用 Excel2Latex 制作表格,但我一直收到过满和欠满错误,以及一个未定义的控制序列。我也非常想在表格字段中使用 \cite{},但无论我做什么,我都会不断收到错误。如果这个问题多次出现,我该如何修复,以免一直遇到相同的错误?这是表格:

\begin{table}[htbp]
  \centering
    \begin{tabular}{|c|p{11.715em}|p{11.715em}|p{11.715em}|}
    \hline
          & \multicolumn{1}{c|}{\textbf{Express.js/Node.js }} & \multicolumn{1}{c|}{\textbf{ASP.NET Core}} & \multicolumn{1}{c|}{\textbf{Flask (Python)}} \bigstrut\\
    \hline
    \textit{Learning curve} & Prior knowledge with technology.Very lightweight, can be picked up quickly with existing JavaScript knowledge. & Prior knowledge with technology. Not lightweight.  & Some prior knowledge with Python. Flexible micro framework and easy to learn. \bigstrut\\
    \hline
    \textit{Supportability} & Extensive community, open source project, easy to get support. Uses JavaScript which is one of the most popular languages. & Created by Microsoft, detailed documentation, popular language  & Popular framework using python which is a popular language , with diverse forums and chat groups to get help.  \bigstrut\\
    \hline
    \textit{License Cost} & \multicolumn{1}{l|}{Open Source.} & \multicolumn{1}{l|}{Open Source.} & \multicolumn{1}{l|}{BSD License (free).} \bigstrut\\
    \hline
    \textit{Scalability} & Good scalability, can be integrated with containers.  & Highly scalable, often used in enterprise solutions. & Flask alone does not scale well, but requires middleware and or libraries before being able to scale well. \bigstrut\\
    \hline
    \textit{File Structure} & Free folder/File structure & Standardized MVC folder structure. & Free structure, but proposes a layout in tutorial. \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:serveranalysis}%
  \caption{Server-Side Analysis}
\end{table}%

此处未定义控制序列

这里人满为患

这里还未满

答案1

我建议根据tabularx和进行以下重新设计booktabs

在此处输入图片描述

\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\begin{document}

\begin{table}[htbp]
  \centering
    \begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash\itshape}p{2.2cm}LLL}
    \toprule
          & \multicolumn{1}{c}{\textbf{Express.js/Node.js }} & \multicolumn{1}{c}{\textbf{ASP.NET Core}} & \multicolumn{1}{c}{\textbf{Flask (Python)}} \\
    \midrule
    Learning curve & Prior knowledge with technology.Very lightweight, can be picked up quickly with existing JavaScript knowledge. & Prior knowledge with technology. Not lightweight.  & Some prior knowledge with Python. Flexible micro framework and easy to learn. \\
    \textit{Supportability} & Extensive community, open source project, easy to get support. Uses JavaScript which is one of the most popular languages. & Created by Microsoft, detailed documentation, popular language  & Popular framework using python which is a popular language , with diverse forums and chat groups to get help.  \\
    License Cost & Open Source. & Open Source. & BSD License (free). \\
    Scalability & Good scalability, can be integrated with containers.  & Highly scalable, often used in enterprise solutions. & Flask alone does not scale well, but requires middleware and or libraries before being able to scale well. \\
    File Structure & Free folder/File structure & Standardized MVC folder structure. & Free structure, but proposes a layout in tutorial. \\
    \bottomrule
    \end{tabularx}%
  \label{tab:serveranalysis}%
  \caption{Server-Side Analysis}
\end{table}%


\end{document}

答案2

如果您将文本放入较窄的列中并要求文本左右对齐,则无法避免水平盒子过满和过少的情况。它们只是警告,至于是否需要关心某些警告,则取决于您,因为输出太丑或超出了页面宽度。

由于页面宽度通常是固定的,因此有两种方法可以解决空间太小的问题。第一种方法是使用较小的字体,第二种方法是将表格横过来。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{rotating}
\begin{document}

\begin{table}
  \centering
  {\footnotesize
  \begin{tabularx}{\textwidth}{@{}p{2cm}XXX@{}}
    \toprule
          & \textbf{Express.js/Node.js} & \textbf{ASP.NET Core} & \textbf{Flask (Python)}\\
    \midrule
    \textit{Learning curve} & Prior knowledge with technology.Very lightweight, can be picked up quickly with existing JavaScript knowledge. & Prior knowledge with technology. Not lightweight.  & Some prior knowledge with Python. Flexible micro framework and easy to learn.\\
    \midrule
    \textit{Supportability} & Extensive community, open source project, easy to get support. Uses JavaScript which is one of the most popular languages. & Created by Microsoft, detailed documentation, popular language  & Popular framework using python which is a popular language , with diverse forums and chat groups to get help.  \\
    \midrule
    \textit{License Cost} & Open Source & Open Source & BSD License (free) \\
    \midrule
    \textit{Scalability} & Good scalability, can be integrated with containers.  & Highly scalable, often used in enterprise solutions. & Flask alone does not scale well, but requires middleware and or libraries before being able to scale well. \\
    \midrule
    \textit{File Structure} & Free folder/File structure & Standardized MVC folder structure. & Free structure, but proposes a layout in tutorial. \\
    \bottomrule
  \end{tabularx}%
  }
  \caption{Server-Side Analysis}
\end{table}

\begin{sidewaystable}
  \centering
\begin{tabularx}{\textwidth}{@{}cXXX@{}}
    \toprule
          & \textbf{Express.js/Node.js} & \textbf{ASP.NET Core} & \textbf{Flask (Python)}\\
    \midrule
    \textit{Learning curve} & Prior knowledge with technology.Very lightweight, can be picked up quickly with existing JavaScript knowledge. & Prior knowledge with technology. Not lightweight.  & Some prior knowledge with Python. Flexible micro framework and easy to learn.\\
    \midrule
    \textit{Supportability} & Extensive community, open source project, easy to get support. Uses JavaScript which is one of the most popular languages. & Created by Microsoft, detailed documentation, popular language  & Popular framework using python which is a popular language , with diverse forums and chat groups to get help.  \\
    \midrule
    \textit{License Cost} & Open Source & Open Source & BSD License (free) \\
    \midrule
    \textit{Scalability} & Good scalability, can be integrated with containers.  & Highly scalable, often used in enterprise solutions. & Flask alone does not scale well, but requires middleware and or libraries before being able to scale well. \\
    \midrule
    \textit{File Structure} & Free folder/File structure & Standardized MVC folder structure. & Free structure, but proposes a layout in tutorial. \\
    \bottomrule
  \end{tabularx}
  \caption{Server-Side Analysis}
\end{sidewaystable}
\end{document}

相关内容