[Tex/LaTex] Creating a simple table article; multi line table headings, display date on same line as caption and double underlines

datetimeisodatelongtabletables

I have written my first LaTeX document, and although it broadly looks like how I want it to, I want to polish it further to give it a bit more of a profession look – alas, this si where I have come unstuck.

I am trying to achieve the following things in my document:

  1. Create a table header that continues across pages (I'm using the longtable package)

  2. Set my column headings to specific widths (so that the text wraps in the column) instead of the table column width increasing with the length of the column heading text.

  3. Display the date in the caption on the same line. Another nice to have would be to be able to format the date to something more like 18Apr12. However despite trying several online examples that use the isodate package – I was unable to get it to work.

  4. Apply a double underline (of a different color) to a specific cell.

This is what I have managed to get so far, after a day of trying:

\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}

I'd be grateful for some pointers/tips on how to fix the tex code above to resolve these issues.

Best Answer

These are too many questions at a time. I think I have solutions for first two and close solutions to questions three and four.

  1. I defined different headers for long table.

  2. Defined a column format using p{}.

  3. datetime is used for the third and

  4. xcolor with table option is used to do coloring.

\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}

enter image description here

enter image description here

Related Question