RENARD Francois 144138 wrote:

Does somebody know how to color a line of a table in LYX ?

You need the package colortbl, see the attached example.
For the colored column, you need some background of customized tables. It's described in the section "Customized table cell format" of

http://wiki.lyx.org/pmwiki.php/LyX/Tables

I'll add a section about color to this page in the next days.

regards Uwe
#LyX 1.3 created this file. For more info see http://www.lyx.org/
\lyxformat 221
\textclass scrartcl
\begin_preamble
\usepackage{color}
\usepackage{colortbl}

\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
\newcolumntype{V}{>{\columncolor{darkgreen}}c}
\end_preamble
\options fleqn,tablecaptionabove
\language ngerman
\inputencoding auto
\fontscheme ae
\graphics default
\paperfontsize 12
\spacing single 
\papersize a4paper
\paperpackage a4
\use_geometry 0
\use_amsmath 1
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 4
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\quotes_language german
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle empty
\bullet 1
        1
        34
        -1
\end_bullet
\bullet 2
        2
        35
        -1
\end_bullet
\bullet 3
        2
        7
        -1
\end_bullet

\layout Standard
\align center 
If you only need colored text, mark the cells and choose a character color
 from the menu layout -> character:
\layout Standard
\align center 

\begin_inset  Tabular
<lyxtabular version="3" rows="3" columns="3">
<features>
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" rightline="true" 
width="0">
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color green
a
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color red
b
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\color red
c
\end_inset 
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color green
d
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color blue
e
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\color blue
f
\end_inset 
</cell>
</row>
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color green
g
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color blue
h
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\color blue
i
\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\layout Standard

In any other cases use the package 
\series bold 
colortbl
\series default 
, see the LaTeX preamble.
 A column is colored with the command 
\series bold 

\backslash 
columncolor
\series default 
, that is inserted inside a 
\series bold 
>{}
\series default 
-command as the LaTeX-argument of the column in LyX's table dialog.
 
\series bold 
>{}
\series default 
 means, that the commands inside the braces are applyed before the cell
 is created.
 For a further description of customized columntypes, have a look at
\layout Standard


\series bold 
http://wiki.lyx.org/pmwiki.php/LyX/Tables
\layout Standard

A Row is colored wit the command 
\series bold 

\backslash 
rowcolor
\series default 
, a cell with the command 
\series bold 

\backslash 
cellcolor
\series default 
.
 If you want to color a character inside a row or cell, which is colored
 with 
\backslash 
row- or 
\backslash 
cellcolor, mark only the character and choose a color in the menu layout
 -> character (the ERT mustn't be colored).
\layout Standard

It is also possible with self-defined colors, like used 
\begin_inset Quotes gld
\end_inset 

darkgreen
\begin_inset Quotes grd
\end_inset 

 of the first column:
\layout Standard
\align center 

\begin_inset  Tabular
<lyxtabular version="3" rows="3" columns="3">
<features>
<column alignment="center" valignment="top" leftline="true" width="0" 
special="V">
<column alignment="center" valignment="top" width="0">
<column alignment="center" valignment="top" width="0">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
rowcolor{cyan}
\end_inset 


\color magenta
a
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color red
b
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\color red
c
\end_inset 
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color yellow
d
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color blue
e
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\color blue
f
\end_inset 
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color yellow
g
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard


\color blue
h
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard


\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
cellcolor{magenta}
\end_inset 


\color green
i
\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\the_end

Attachment: newfile2.pdf
Description: Adobe PDF document

Reply via email to