LaTeX forum ⇒ LyXChanging equation number colour

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Jos Gibbons
Posts: 4
Joined: Thu Sep 10, 2015 10:59 am

Changing equation number colour

Postby Jos Gibbons » Thu Sep 10, 2015 11:09 am

I'm writing my thesis in LyX. I frequently use long greyedout notes that contain display-line equations.* One-line equations in my thesis automatically number themselves, but some multi-line equation environments are necessary, because of multiple related equations or equations too long for one line. I manually number the ends of equations in these environments. While automatic numbers in greyedout notes are the same colour as the greyedout text, the manual ones are black (which is rather jarring). How can I make them grey instead?

*I explain to the reader early on that I use these notes for discussions that are too long for footnotes, but need to be differently coloured to indicate the sentences immediately after them follow from those immediately before. For example, "it can be shown that X; grey proof of X; one corollary of X is..."

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Thu Sep 10, 2015 4:18 pm

Hi and welcome to the LaTeX community!

Can you give us some example code how you're creating these multi line equations? Maybe some minimal LyX document? You could attach it to your next post.

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

User avatar
Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 10, 2015 4:23 pm

Seems a bit like an xy-problem to my. Instead of adjusting the colouring of the manually set numbers, wouldn't it be easier to automatically create numbers. Advantage: If for any reason your numbers change, you don't have to retag equations.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Jos Gibbons
Posts: 4
Joined: Thu Sep 10, 2015 10:59 am

Postby Jos Gibbons » Thu Sep 10, 2015 4:48 pm

Perhaps my automatic/by-hand description was misleading. The numbers still automatically update as things change, track equation labels that I add etc. It's just that right-click --> add equation number results in black text, whereas 1-line equations that are automatically numbered due to preamble code have grey numbers.

User avatar
Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 10, 2015 5:02 pm

Can you show us a minimal LyX file, or even better, a LaTeX export, so we see what is actually going on? For a LaTeX helper, the words i click on button xy is like saying Take a look at this nice flower to a blind person. LaTeX code on the other hand can be read even by blind people.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Jos Gibbons
Posts: 4
Joined: Thu Sep 10, 2015 10:59 am

Postby Jos Gibbons » Thu Sep 10, 2015 5:34 pm

I apologise for not noticing cgneider's post. Here's the LaTeX output of a minimal example:
  1. %% LyX 2.1.3 created this file. For more info, see http://www.lyx.org/.
  2. %% Do not edit unless you really know what you are doing.
  3. \documentclass[british]{report}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[latin9]{inputenc}
  6. \setcounter{secnumdepth}{3}
  7. \setcounter{tocdepth}{3}
  8. \usepackage{color}
  9. \definecolor{note_fontcolor}{rgb}{0.800781, 0.800781, 0.800781}
  10. \usepackage{babel}
  11. \usepackage[unicode=true,pdfusetitle,
  12. bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
  13. breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
  14. {hyperref}
  15.  
  16. \makeatletter
  17.  
  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
  19. %% The greyedout annotation environment
  20. \newenvironment{lyxgreyedout}
  21. {\textcolor{note_fontcolor}\bgroup\ignorespaces}
  22. {\ignorespacesafterend\egroup}
  23.  
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
  25. \usepackage{xcolor}
  26. \renewcommand\theequation{\arabic{section}.\arabic{equation}}
  27. \renewcommand{\[}{\begin{equation}}
  28. \renewcommand{\]}{\end{equation}}
  29.  
  30. \makeatother
  31.  
  32. \begin{document}
  33.  
  34. \section{A minimal example in the report standard class}
  35.  
  36. First I work with ``normal'' black text. This is an equation:
  37. \[
  38. a=b.
  39. \]
  40.  
  41.  
  42. Here are two equations:
  43.  
  44. \begin{eqnarray}
  45. c & = & d,\\
  46. e & = & f.
  47. \end{eqnarray}
  48.  
  49.  
  50. \begin{lyxgreyedout}
  51. My problem has always been that the following equation numbers are
  52. black, whereas I would prefer them to be the colour of this greyedout
  53. environment:
  54.  
  55. \begin{eqnarray}
  56. i & = & j,\\
  57. k & = & l.
  58. \end{eqnarray}
  59.  
  60.  
  61. I wrote this minimal example to try to illustrate that, despite that
  62. problem, single-line equation environments had grey numbers. For whatever
  63. reason, now even they have black numbers, viz.
  64. \[
  65. g=h.
  66. \]
  67.  
  68.  
  69. How can I make equation numbers grey in greyedout environments?%
  70. \end{lyxgreyedout}
  71.  
  72. \end{document}

User avatar
Johannes_B
Site Moderator
Posts: 3854
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 10, 2015 6:33 pm

the eqnarray environment has several issues, it is recommended not to use it. Using amsmath (or rather mathtools for some extra features) you can use align for the very same functunality.

  1. \documentclass[british]{report}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[latin9]{inputenc}
  4. \usepackage{xcolor}%note the x
  5. %\definecolor{note_fontcolor}{rgb}{0.800781, 0.800781, 0.800781}
  6. \colorlet{note_fontcolor}{gray}
  7. \usepackage{babel}
  8.  
  9.  
  10. \newenvironment{lyxgreyedout}
  11. {\textcolor{note_fontcolor}\bgroup\ignorespaces}
  12. {\ignorespacesafterend\egroup}
  13.  
  14. \usepackage{xcolor}
  15. \renewcommand\theequation{\arabic{section}.\arabic{equation}}
  16. \renewcommand{\[}{\begin{equation}}%really really not recommended
  17. \renewcommand{\]}{\end{equation}}
  18.  
  19.  
  20. \usepackage{mathtools}
  21. \begin{document}
  22.  
  23. \section{A minimal example in the report standard class}
  24.  
  25. First I work with ``normal'' black text. This is an equation:
  26. \[
  27. a=b.
  28. \]
  29.  
  30. Here are two equations:
  31.  
  32. \begin{align}
  33. c &= d,\\
  34. e &= f.
  35. \end{align}
  36.  
  37. \begin{lyxgreyedout}
  38. My problem has always been that the following equation numbers are
  39. black, whereas I would prefer them to be the colour of this greyedout
  40. environment:
  41.  
  42. \begin{align}
  43. i &= j,\\
  44. k &= l.
  45. \end{align}
  46.  
  47.  
  48. I wrote this minimal example to try to illustrate that, despite that
  49. problem, single-line equation environments had grey numbers. For whatever
  50. reason, now even they have black numbers, viz.
  51. \[
  52. g=h.
  53. \]
  54.  
  55.  
  56. How can I make equation numbers grey in greyedout environments?%
  57. \end{lyxgreyedout}
  58. \end{document}


I am pretty sure that LyX can use align with ease. Else it would be a horrible tool and not be used by many people.


btw: Redefining \[ isn't really a good idea. It works, but it is really against convention.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Jos Gibbons
Posts: 4
Joined: Thu Sep 10, 2015 10:59 am

Postby Jos Gibbons » Thu Sep 10, 2015 7:32 pm

Thank you. Replacing eqnarray with align fixed the colour problem.


Return to “LyX”

Who is online

Users browsing this forum: No registered users and 4 guests