LyXChanging equation number colour

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

Changing equation number colour

Post by Jos Gibbons »

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..."

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Changing equation number colour

Post by cgnieder »

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
site moderator & package author
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Changing equation number colour

Post by Johannes_B »

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

Re: Changing equation number colour

Post by Jos Gibbons »

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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Changing equation number colour

Post by Johannes_B »

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

Changing equation number colour

Post by Jos Gibbons »

I apologise for not noticing cgneider's post. Here's the LaTeX output of a minimal example:

Code: Select all

%% LyX 2.1.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{color}
\definecolor{note_fontcolor}{rgb}{0.800781, 0.800781, 0.800781}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% The greyedout annotation environment
\newenvironment{lyxgreyedout}
  {\textcolor{note_fontcolor}\bgroup\ignorespaces}
  {\ignorespacesafterend\egroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xcolor}
\renewcommand\theequation{\arabic{section}.\arabic{equation}}
\renewcommand{\[}{\begin{equation}} 
\renewcommand{\]}{\end{equation}}

\makeatother

\begin{document}

\section{A minimal example in the report standard class}

First I work with ``normal'' black text. This is an equation:
\[
a=b.
\]


Here are two equations:

\begin{eqnarray}
c & = & d,\\
e & = & f.
\end{eqnarray}


\begin{lyxgreyedout}
My problem has always been that the following equation numbers are
black, whereas I would prefer them to be the colour of this greyedout
environment:

\begin{eqnarray}
i & = & j,\\
k & = & l.
\end{eqnarray}


I wrote this minimal example to try to illustrate that, despite that
problem, single-line equation environments had grey numbers. For whatever
reason, now even they have black numbers, viz. 
\[
g=h.
\]


How can I make equation numbers grey in greyedout environments?%
\end{lyxgreyedout}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Changing equation number colour

Post by Johannes_B »

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.

Code: Select all

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{xcolor}%note the x
%\definecolor{note_fontcolor}{rgb}{0.800781, 0.800781, 0.800781}
\colorlet{note_fontcolor}{gray}
\usepackage{babel}


\newenvironment{lyxgreyedout}
{\textcolor{note_fontcolor}\bgroup\ignorespaces}
{\ignorespacesafterend\egroup}

\usepackage{xcolor}
\renewcommand\theequation{\arabic{section}.\arabic{equation}}
\renewcommand{\[}{\begin{equation}}%really really not recommended
\renewcommand{\]}{\end{equation}}


\usepackage{mathtools}
\begin{document}

\section{A minimal example in the report standard class}

First I work with ``normal'' black text. This is an equation:
\[
	a=b.
\]

Here are two equations:

\begin{align}
	c &=  d,\\
	e &=  f.
\end{align}

\begin{lyxgreyedout}
	My problem has always been that the following equation numbers are
	black, whereas I would prefer them to be the colour of this greyedout
	environment:

	\begin{align}
		i &=  j,\\
		k &=  l.
	\end{align}


	I wrote this minimal example to try to illustrate that, despite that
	problem, single-line equation environments had grey numbers. For whatever
	reason, now even they have black numbers, viz.
	\[
		g=h.
	\]


	How can I make equation numbers grey in greyedout environments?%
\end{lyxgreyedout}
\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

Re: Changing equation number colour

Post by Jos Gibbons »

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