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.

| improve this question | | | | |

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

| improve this answer | | | | |
  • Nice and creative solution. – scottkosty Apr 26 '13 at 0:50
  • Great - so easy! – JS1204 Apr 28 '13 at 17:36
  • Great! How about vertical lines? – AimForClarity Oct 14 '18 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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