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 a problem with colortbl \rowcolor that insists on making the color width of the rows longer than the actual row width. Snippet of the code:

\documentclass[a5paper, 10pt, twoside]{article}
\usepackage[english, norsk]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{amssymb, amsmath}
\usepackage{color}
\usepackage{graphicx, tabularx, fancyhdr, colortbl}
\usepackage[a5paper, height=18.0cm, inner=1.3cm, outer=0.65cm]{geometry}
\usepackage[colorlinks, linkcolor=black]{hyperref}
\usepackage{supertabular}
\usepackage{hyperref}
\usepackage[ttbnonum]{flowfram}

\twocolumn[1-2]

\begin{document}
\tiny
\begin{supertabular}{|p{0.38\linewidth}l@{\,}|lrl|}
   \multicolumn{5}{p{0.7\linewidth}}{\textbf{\raggedright \\ \footnotesize No name }} \\
  \hline
  \rowcolor[gray]{0.8} (project) (Ss) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{3B:} & \hspace{-10pt}2 \\
  \rowcolor[gray]{1.0} (project) (!) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{3C:} & \hspace{-10pt}2 \\
  \rowcolor[gray]{0.8} (project) (Ds) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{5C:} & \hspace{-10pt}2b \\
  \rowcolor[gray]{1.0} (project) (Ss) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{13A:} & \hspace{-10pt}7 \\
  \rowcolor[gray]{0.8} (project) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{13B:} & \hspace{-10pt}1 \\
  \rowcolor[gray]{1.0} (project) (Ss) &  & \hspace{-8pt} Fp north & \hspace{-8pt} \textbf{13B:} & \hspace{-10pt}2 \\
\end{supertabular}
\end{document}

The table expands across several pages (its genereated by some C++ code I'm making). The output looks like this:

enter image description here

The problem lies with the leading @{} in the definition of the supertable (I have to use super table since that is the only one compatible with flowfram).

I could put a negative \hspace, but that will still "indent" the second line in the p{...}.

(Been struggling with this one for 3 years now...)

share|improve this question
    
Are you adding @{} by yourself to get rid of extra column space? –  Harish Kumar Apr 19 '12 at 10:47
    
Of course you know that your code example does not produce the problem you're talking about. –  egreg Apr 19 '12 at 12:20
    
Yup writing everything. I'm acutally making a pdf from some custom xml data files that I have, and I don't know up front what each single line will be (currently I have 900 "objects" in the xml file). Thus I must be carefull to make "everything" fit and look nice. –  Truls Apr 19 '12 at 13:31
add comment

1 Answer

up vote 3 down vote accepted

Your MWE can be simplified,

\documentclass[a5paper, 10pt, twoside]{article}

\usepackage{colortbl}

\begin{document}\makeatletter

\begin{tabular}{@{}|@{}p{0.38\linewidth}l@{\,}|lrl|}
  \hline
  \rowcolor{red}(project)(Ss) &  &  Fp north &  \textbf{3B:} & \hspace{-10pt}2 \\
    (ddproject) (!) &  &  Fp north &  \textbf{3C:} & \hspace{-10pt}2 \\
\end{tabular}
\end{document}

shows the same behaviour

enter image description here

Looks like a bug to me, but can't look now, but I thought I would post the simplified MWE to help anyone looking at this.

It is a bug (I think) but you can avoid it by

 \setlength\tabcolsep{0pt}

you will then probably have to insert some spacing within the table to space things out a bot more.

\begin{tabular}{@{}|@{}p{0.38\linewidth}>{\hspace{12pt}}l|>{\hspace{12pt}}l>{\hspace{12pt}}r>{\hspace{12pt}}l|}
  \hline
  \rowcolor{red}(project)(Ss) &  &  Fp north &  \textbf{3B:} & \hspace{-10pt}2 \\
    (ddproject) (!) &  &  Fp north &  \textbf{3C:} & \hspace{-10pt}2 \\
\end{tabular}
share|improve this answer
    
Hmm... That might work for me. The laatex code does'nt really have to be "neat" as its generated by a c++ program. Will try it out. –  Truls Apr 19 '12 at 13:34
    
Tried it out. Its a good workaround for me. Now I can define the separators in a more understandable way: use positive values for the hspace. Super! thanks a lot! –  Truls Apr 19 '12 at 14:39
    
Follow up question, David: What does the @{} around the first "|" do, now that the colsep=0? –  Truls Apr 19 '12 at 15:10
    
it doesn't do anything (actually it does do soemthing, it stopks TeX adding \hskip0pt in that place but mainly it is just left over from my trials) –  David Carlisle Apr 19 '12 at 15:21
add comment

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.