LyXEnumeration function in texts

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Mythologia
Posts: 1
Joined: Fri May 27, 2016 2:18 pm

Enumeration function in texts

Post by Mythologia »

Hellor everyone,
I've just started using Lyx for my chemistry thesis and so far quite happy with its features. At the moment I have one problem.
In my text I want to refer to certain molecules with numbers.
Is there a way that I can link all numbers of the same structure, so if I change one of them, the others change as well. Additionally I'd like enumerate different structures.

Example:
blablabla Structure 1 blablabla Structure 2 blablabla Structure 1

I add one structure with a new number before Structure 1

blablabla (New) Structure 1 blablabla Structure 2 blablabla Structure 3 blablabla Structure 2

I hope you understand my problem and hope you can help me with it :D
Thanks in advance

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

Hafting
Posts: 1
Joined: Thu Jun 09, 2016 12:07 pm

Re: Enumeration function in texts

Post by Hafting »

I see two ways of getting what you want. One would be to write a lot of (La)TeX code to get exactly what you want. There are other forums for the details on LaTeX, LyX lets you put in any amount of (La)TeX code you need.

The simpler way would be to create an enumerated list with you molecules, with one labeled list item per molecule. You can then insert cross references to your molecules throughout the text. When you print (or make PDF), LyX will use LaTeX to place numbers where the cross references are.

For example:

1. [Label H2O] The H2O molecule...
2. [Label CO2] The CO2 molecule...
3. [Label C2H5OH] The ethanol molecule...

Elsewhere in the text, you might have "Water is an important molecule...", it will print as "Water 1 is an important molecule..."

If you later add H2SO4 as molecule number one, water will automatically be renumbered to "2". Both in the list, and in every cross reference.

This works very well if you want to have such a list of molecules in your printed document. If you don't want the list, just the numbering, move the list to the very last page, and don't print that page when you print the thesis. If that seems too kludgy, consider the LaTeX solution instead.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Enumeration function in texts

Post by cgnieder »

This is what the chemnum package is for:

Code: Select all

\documentclass{article}
\usepackage{chemnum}

\begin{document}

Water (\cmpd{water}) and ethanol (\cmpd{ethanol}) do mix fairly well.  Both
\cmpd{water,ethanol} are\ldots

\end{document}
chemnum.png
chemnum.png (5.89 KiB) Viewed 3873 times
Regards
site moderator & package author
Post Reply