Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
I am unable to format the code properly. Don't know why. It is not working. Somebody pl. format it for me. –  Harish Kumar Apr 20 '12 at 8:49
    
For formatting a code block directly following a list, you'll have to separate the list and code using, for example, a comment (<!-- -->). This is explained in meta.stackexchange.com/a/99637/165548 –  Jake Apr 20 '12 at 9:27
    
@Jake: Thanks. Didn't know it. –  Harish Kumar Apr 20 '12 at 10:38
    
@HarishKumar +1 for the example. It does almost all of the things I wanted to do, and I can probably work from what you have provided. BTW rgb.tex is a file which contains color definitions using the RGB pallete. –  Homunculus Reticulli Apr 20 '12 at 19:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.