表格中的问题

表格中的问题

在此处输入图片描述

因此,当我尝试创建一个大表时出现了这个错误。

这是我使用过的代码:

\documentclass[journal]{IEEEtran}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{colortbl}
\newcommand{\gray}{\rowcolor[gray]{.90}}
\newcommand{\rgb}{\rowcolor[rgb]{0,1,0}}
\usepackage{tabularx,booktabs}

\begin{document}

\begin{figure}[h!]
\begin{center}
%\resizebox{16cm}{!} {
      \begin{tabular}{|>{\columncolor[gray]{0.9}}c|c|c|c|c|c|c|c|}
    \hline
    \rowcolor[gray]{0.9}
    Problem description & Flight phase & Consequence, effect & 
Classification & Mitigator measure & Defense & Probability \\ \hline 
Actuator A1 Fail& Taxi & Wing gets stuck, high chances of canceling flight & E & Actuator divided in more sections & NA & NA \\ \hline
Actuator A1 Fail& Take-off & Wing gets stuck, take-off becomes dangerous because there may be a possible disequilibrium & C & Divide the actuator in several pieces & Very experimented pilot to control the situation & $10^{-5}$\\ \hline
   Actuator A1 Fail& Cruise & Wing gets stuck, disequilibrium plus chances of stall  & D & Divide the actuator in several parts & Find the equilibrium with the help of the engines power plus double hydraulic system in the actuators & $10^{-5}$\\ \hline
    Actuator A1 Fail & Landing & Wing gets stuck, we could easily find a missed-approach situation where we could get unaligned with the runway & C & Several actuators so lower chances of losing full control & NA & $10^{-5}$ \\ \hline
    \end{tabular}
%   }
    \caption{table 1}
\end{center}
\end{figure}

\end{document}

答案1

另一个基于tabularxmakecell和 的解决方案eqparbox。我在行中添加了一些垂直填充:

\documentclass[journal]{IEEEtran}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{colortbl}
\newcommand{\gray}{\rowcolor[gray]{.90}}
\newcommand{\rgb}{\rowcolor[rgb]{0,1,0}}
\usepackage{tabularx,booktabs, makecell}
\usepackage{ragged2e, eqparbox}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.3pt}

\begin{document}

\begin{table*}
  \small
  \setlength\extrarowheight{2pt}
  \renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}
  \renewcommand\theadfont{\small}
  \begin{tabularx}{\linewidth}{|>{\columncolor[gray]{0.9}}c|c|X|c|X|X|c|}
    \hline
    \rowcolor[gray]{0.9}
    \raisebox{0pt}[1.25\height][1.25\depth]{\eqparbox{Pd}{Problem\\ description}} &\eqparbox{Fd}{Flight\\ phase} & \thead{Consequence, effect} &
    \thead{Classif.} & \thead{Mitigator measure} & \thead{Defense} & \thead{Probab.} \\ \hline
    Actuator A1 Fail & Taxi & Wing gets stuck, high chances of canceling flight & E & Actuator divided in more sections & NA & NA \\ \hline
    Actuator A1 Fail & Take-off & Wing gets stuck, take-off becomes dangerous because there may be a possible disequilibrium & C & Divide the actuator in several pieces & Very experimented pilot to control the situation & $10⁻⁵$ \\ \hline
    Actuator A1 Fail & Cruise & Wing gets stuck, disequilibrium plus chances of stall & D & Divide the actuator in several parts & Find the equilibrium with the help of the engines power plus double hydraulic system in the actuators & $10⁻⁵$ \\ \hline
    Actuator A1 Fail & Landing & Wing gets stuck, we could easily find a missed-approach situation where we could get unaligned with the runway & C & Several actuators so lower chances of losing full control & NA & $10⁻⁵$ \\ \hline
  \end{tabularx}
  \caption{table 1}
\end{table*}

\end{document} 

在此处输入图片描述

答案2

一些观察和评论:

  • 使用table环境,而不是figure环境。

  • 文档IEEEtran类使用双列页面布局。不幸的是,表格太宽,无法容纳在一列中。使用环境table*而不是table环境,让表格材料占据两列的宽度。

  • 在环境内部table*,使用tabularx宽度设置为 的环境\textwidth

  • X对 7 列环境中的第 3、5 和 6 列使用列类型(的修改形式)tabularx

  • 最后但并非最不重要的一点是,由于您已经加载了booktabs包,请使用其宏——尤其是\toprule、、\midrule和——并且不要在任何地方使用。此外,不要使用任何垂直规则;它们根本就没有必要。另外,请考虑不要对标题行和左侧列使用阴影。\bottomrule\addlinespace\hline

顺便说一句,我非常希望第二种情况下的防御措施涉及“非常有经验的飞行员”而不是“非常有经验的飞行员”...... :-)

完整的 MWE:

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage{tabularx,booktabs,ragged2e,newtxmath}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\begin{document}

\begin{table*}
\begin{tabularx}{\textwidth}{@{}llYcYYc@{}}
\toprule
Problem description & Flight phase & Consequence, effect & Classification & Mitigator measure & Defense & Probability \\ 
\midrule
Actuator A1 Fail& Taxi     & Wing gets stuck, high chances of canceling flight & E & Actuator divided in more sections & NA & NA \\ \addlinespace
Actuator A1 Fail& Take-off & Wing gets stuck, take-off becomes dangerous because there may be a possible disequilibrium & C & Divide the actuator in several pieces & Very experienced pilot to control the situation & $10^{-5}$\\ \addlinespace
Actuator A1 Fail& Cruise   & Wing gets stuck, disequilibrium plus chances of stall  & D & Divide the actuator in several parts & Find the equilibrium with the help of the engines power plus double hydraulic system in the actuators & $10^{-5}$\\ \addlinespace
Actuator A1 Fail& Landing  & Wing gets stuck, we could easily find a missed-approach situation where we could get unaligned with runway & C & Several actuators, hence lower chances of losing full control & NA & $10^{-5}$ \\
\bottomrule
\end{tabularx}

\medskip
\caption{A two-column table}
\end{table*}
\end{document} 

答案3

\documentclass[journal]{IEEEtran}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{colortbl}
\newcommand{\gray}{\rowcolor[gray]{.90}}
\newcommand{\rgb}{\rowcolor[rgb]{0,1,0}}
\usepackage{tabularx,booktabs}
\begin{document}
\begin{figure}[h!]
\begin{center}
\begin{tabular}{|>{\columncolor[gray {0.9}}p{1.9cm}|p{1cm}|p{3.2cm}|p{1.8cm}|p{3cm}|p{2.4cm}|c|}
\hline
\rowcolor[gray]{0.9}
Problem description & Flight phase & Consequence, effect & Classification & Mitigator measure & Defense & Probability \\ \hline 
Actuator A1 Fail& Taxi & Wing gets stuck, high chances of canceling flight & E & Actuator divided in more sections & NA & NA \\ \hline
Actuator A1 Fail& Take-off & Wing gets stuck, take-off becomes dangerous because there may be a possible disequilibrium & C & Divide the actuator in several pieces & Very experimented pilot to control the situation & $10^{-5}$\\ \hline
Actuator A1 Fail& Cruise & Wing gets stuck, disequilibrium plus chances of stall  & D & Divide the actuator in several parts & Find the equilibrium with the help of the engines power plus double hydraulic system in the actuators & $10^{-5}$\\ \hline
Actuator A1 Fail & Landing & Wing gets stuck, we could easily find a missed-approach situation where we could get unaligned with the runway & C & Several actuators so lower chances of losing full control & NA & $10^{-5}$ \\ \hline
\end{tabular}
\caption{table 1}
\end{center}
\end{figure}
\end{document}

正在运行。请查看附件的屏幕截图。在此处输入图片描述

相关内容