创建一个简单的表格文章;多行表格标题,在同一行显示日期和标题以及双下划线

创建一个简单的表格文章;多行表格标题,在同一行显示日期和标题以及双下划线

我已经编写了我的第一个 LaTeX 文档,尽管它大体上看起来符合我的要求,但我想进一步完善它,使它看起来更专业一些 - 唉,这就是我失败的地方。

我试图在我的文档中实现以下目标:

  1. 创建一个跨页面的表头(我正在使用包longtable

  2. 将我的列标题设置为特定宽度(以便文本在列中换行),而不是表格列宽度随着列标题文本的长度而增加。

  3. 在同一行的标题中显示日期。另一个不错的功能是能够将日期格式化为更像 18Apr12 的格式。然而,尽管尝试了几个使用该isodate包的在线示例 - 我仍然无法让它工作。

  4. 对特定单元格应用双下划线(不同颜色)。

经过一天的尝试,我目前得到的结果如下:

\documentclass[english]{article}

\usepackage{times}
\usepackage{babel}
\usepackage{color}
\usepackage{ulem}
\usepackage{longtable}
\usepackage{datetime}
\usepackage[margin=0.5in]{geometry}
\input{rgb}

\begin{document}
\begin{center}
\begin{longtable}{|l|l|l|l|l|l|l|}
\caption{This is a long caption for table generated as at \today}\\
\hline
Surname & Column One & Column Two & Column Three & Column Four & Column Five & Column Six \\ \hline
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
\end{longtable}
\end{center}
\end{document}

我将非常感激一些关于如何修复上述 tex 代码以解决这些问题的指点/提示。

答案1

这些问题太多了。我认为前两个问题我已经有了答案,第三个和第四个问题也接近答案了。

  1. 我为长表定义了不同的标题。

  2. 使用 定义列格式p{}

  3. datetime用于第三和

  4. xcolorwithtable选项用于进行着色。

\documentclass[english]{article}
\usepackage{times}
\usepackage{babel}
\usepackage[table]{xcolor} %use this instead of color, table option for coloring table lines
\usepackage{ulem}
\usepackage{longtable}
\usepackage[font=bf,singlelinecheck=on,format=hang,margin=2cm,labelfont=bf]{caption}
\usepackage[short,nodayofweek]{datetime}% to define date format
\newdateformat{mydate}{\THEDAY \THEMONTH \twodigit{\THEYEAR}}
\newdateformat{usvardate}{%
{\THEDAY} \shortmonthname[\THEMONTH], \THEYEAR}
\usepackage[margin=0.5in]{geometry}
%\input{rgb} % what is rgb?
%-------------------------------------
\begin{document}
%\rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray}
%\begin{center} % not needed as longtable is centered by default
\begin{longtable}{|l|p{2cm}|l|l|l|l|l|}
\caption{This is a long caption for table generated as at \usvardate\today\ and this may span more than one line for sure}\label{tab:mytable}\\
\hline
Surname & Column One and this is big header & Column Two & Column Three & Column Four & Column Five & Column Six \\ \hline
\endfirsthead
\multicolumn{7}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline
%
Surname & Column One and this is big header & Column Two & Column Three & Column Four & Column Five & Column Six \\ \hline
\endhead
%
\hline \multicolumn{7}{|r|}{{Continued on next page}} \\ \hline
\endfoot
%
\hline
\multicolumn{7}{|r|}%
{{\bfseries \tablename\ \thetable{} -- concluded}} \\
\hline
\endlastfoot
%
\arrayrulecolor{red!75!gray}
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & \multicolumn{1}{>{\columncolor{red!30}[1\tabcolsep]}l|}{5} & 6 \\ \hline
\arrayrulecolor{black}
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
\newpage
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
\rowcolor{blue!25}
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\\hline
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
Oliver & 1 & \color{green}2 & \color{red}\uuline{3} & 4 & 5 & 6 \\ \hline
\end{longtable}
%\end{center}
\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容