4

I have a multi-row table in LyX, with black horizontal borders at the top and bottom of the table. I would like to insert other horizontal borders inside the table that are grey rather than black. Does anyone know how to accomplish this?

I have tried looking in the manuals and online forums to no avail so far.

2

1 Answer 1

4

This is a workaround since LyX does not support the package colortbl at the moment. Please check below steps carefully!

  1. Add \usepackage{colortbl} to the LaTeX Preamble (under "Document > Settings").

  2. Coloring the top rule

    To color the top rule in "blue" put the TeX code/ERT \arrayrulecolor{blue}\hline at the beginning of the first table cell. (If the colored rule did not completely cover original rule you needed to remove the top rule in the LyX table editor.)

  3. Coloring another horizontal rule

    To color a rule below a certain table row in "red" put \tabularnewline\arrayrulecolor{red}% at the end of the last cell of that row.

    Please check the result by using "View Source". The trick is that by using % we make the remaining line a comment. Everything that we make a comment (that is, comes after the %) must be repeated by us in front of \arrayrulecolor.

    For example, if a concerned line ends with \tabularnewline, we will put exactly this in front of \arrayrulecolor, that is, we write \tabularnewline[4ex]\arrayrulecolor{red}%. Or, if the line ends with \tabularnewline[4ex] then we have to put the TeX code \tabularnewline[4ex]\arrayrulecolor{red}%.

  4. Finally, we might want to reset the color to "black" as describe in previous case.

Following all above steps we get a table like this: LyX colortbl

The output is:

PDF output

Note that you can close a TeX code inset by right click "Close Inset": enter image description here

3
  • Nice and creative solution.
    – scottkosty
    Commented Apr 26, 2013 at 0:50
  • Great - so easy!
    – JS1204
    Commented Apr 28, 2013 at 17:36
  • Great! How about vertical lines? Commented Oct 14, 2018 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .