在LaTeX中格式化表格的列 [英] Formatting the columns of a table in LaTeX

查看:139
本文介绍了在LaTeX中格式化表格的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用LaTeX进行文档编制.我无法格式化表格.请参考以下代码段.

I am trying to use LaTeX for documentation. I am unable to format the table. Please refer the following snippet of code.

\begin{table}[!htbp]
\begin{center}
 \begin{tabular}{| m{3cm} | m{3cm} | m{3cm}| m{3cm} | m{3cm} |}
\hline
Software Project & a_a & b_b & c_b & d_b \\
\hline
Organic &   2.4 &  1.05   & 2.5 & 0.38\\
\hline
Semi-detached & 3.0 &  1.12  & 2.5 & 0.35\\
 \hline
 Embedded & 3.6 &  1.20   & 2.5 & 0.32\\
 \hline

推荐答案

您的意思是类似于我在下面发布的代码和屏幕截图吗?

Do you mean something like the code+screenshot I posted below?

如果合适,请记住以下内容:

If that fits, remember what follows:

  1. 检查在序言中是否包含\usepackage{array}
  2. 使用\centering而不是将tabular嵌套到centertable;
  3. 查看列的宽度;
  4. a_a仅在数学模式下起作用:$a_a$;
  5. 检查环境是否正确关闭(粘贴在问题中的代码中缺少\end{tabular}等).
  1. check to have \usepackage{array} in your preamble;
  2. use \centering instead of nesting tabular into center into table;
  3. review the width of the columns;
  4. a_a only works in math mode: $a_a$;
  5. check to have your environments closed properly (\end{tabular}, etc. are missing in the code you pasted in your question).

\documentclass[11pt,a4paper]{article}
\usepackage{array}

\begin{document}

\begin{table}[!htbp]
  \centering
  \begin{tabular}{| m{3.5cm} | m{1.5cm} | m{1.5cm} | m{1.5cm} | m{1.5cm} |}
    \hline
    Software Project & $a_a$ & $b_b$ & $c_b$ & $d_b$\\
    \hline
    Organic & 2.4 & 1.05 & 2.5 & 0.38\\
    \hline
    Semi-detached & 3.0 & 1.12 & 2.5 & 0.35\\
    \hline
    Embedded & 3.6 & 1.20 & 2.5 & 0.32\\
    \hline
  \end{tabular}
\end{table}

\end{document}

这篇关于在LaTeX中格式化表格的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆