## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Longtables :: Setting 'global' properties

Information and discussion about graphics, figures & tables in LaTeX documents.
James Bejon
Posts: 1
Joined: Fri Jan 02, 2015 3:28 pm

### Longtables :: Setting 'global' properties

Dear All,

I’m completely new to tex. My level of ‘expertise’ is currently pasting text into TexShop (I have a Mac) and pressing “Typeset”. I’m hoping someone might be able to help me with a ‘long table’ related question. I want to set some general properties for my longtables so that their top row is always dark grey and so that they’re always horizontally-centred on my pages. I’ve found some documentation on longtables (http://tug.ctan.org/macros/latex/requir ... gtable.pdf), but I don’t yet have the know-how to make sense of it. I'd be very grateful if someone could give me a hand. Below is some code showing where I've got to so far.

James.


Tags:

Harish Kumar
Posts: 2
Joined: Sun Feb 22, 2015 1:39 am
What you have posted is not a minimal working example. Having said that, you are loading some packages which are not necessary to be loaded. For example

% Set for tables\usepackage{colortbl}  %% loaded by xcolor in next line, not needed\usepackage[table]{xcolor}\definecolor{lightgray}{gray}{0.95} \usepackage{longtable,tabu}   %% tabu is not needed\usepackage{array} % for extrarowheight    %% not needed

Your first question can be solved by using the \rowcolor macro provided by xcolor

\rowcolors{1}{gray}{}  %%<-- colour alternate rows with gray colour starting from row 1.

Since you need to colour only the first row, issue \hiderowcolors after the first row.

And regarding your second question of "always horizontally-centred on my pages", some more clarification may be needed. At last, I don't think you can set the colouring properties globally to longtable.

\documentclass[a4paper]{book}\usepackage[table]{xcolor}\usepackage{longtable}\renewcommand{\arraystretch}{1.5}\begin{document} \rowcolors{1}{gray}{}  %%<-- colour alternate rows with gray colour starting from row 1.\begin{longtable}{|p{7.5cm}|p{7.5cm}|}\hline\multicolumn{1}{|c|}{\textbf{Col. 1}} & \multicolumn{1}{c|}{\textbf{Col. 2}} \\ \hline\hiderowcolors         %%% <--- hide row colours after this lineText in Col 1. & Text in Col 2. \\ \hlineText in Col 1. & Text in Col 2. \\ \hlineText in Col 1. & Text in Col 2. \\ \hlineText in Col 1. & Text in Col 2. \\ \hlineText in Col 1. & Text in Col 2. \\ \hline\hline\end{longtable}\end{document}