I'm doing a translation of the Zohar (more than 2000pages) in LyX. There are terms that appear a lot in the text and I'd like not to click with the search button to identify all the occurence of a term in the text but only write the term once e.g. "Elohim" and having it selected and automatically indexed for all the occurences in the text. Is that possibile? Thank you!
-
Guessing that you know how to add a LaTeX preamble in LyX, this answer should be enough. – Fran Jul 12 '20 at 19:03
-
maybe I'm dumb... I'm able to add a LateX preamble in Lyx but I couldn't understand how it works. Can you write explicitly what should I write in the preamble and how should I use it? Thank you! – Dac0 Jul 12 '20 at 20:40
-
mmm... it doesn't seem to work unfortunately – Dac0 Jul 12 '20 at 22:12
-
Man of little faith, see my answer ;) – Fran Jul 12 '20 at 22:26
1 Answers
Following my answer in How to ensure that all pages corresponding to the entries appear in the index are shown?
To adapt this to LyX you only must be aware of what part of this code could be produced by LyX automatically, and what code you must include explicitly. One way to do with an empty new document:
(1) Open the Code preview Pane to verify what is really made with every action.
(2) Add the text "ELISA and PCR", make the word "ELISA" an index entry manually. Then add the Index List as usual in LyX:
The first action will add \index{ELISA} in text but also \usepackage{makeidx}\makeindex, so you should not include it again in the preamble, whereas the "Index" cyan box simply will add \printindex after the text.
(3) In Document > Settings... > LaTeX Preamble add the xesearch code. For instance, this simplified version:
\usepackage{xesearch}
\SearchList{index}{#1\index{{#1}}}{ELISA,PCR}
(4) Optionally, you can include also \usepackage[colorlinks]{hyperref} here, or alternatively add the hyperref support in Document > Settings... > PDF Properties, but be sure of not load it twice!
(5) In order to not index also the index list, between the text and the list, add with Ctrl+L \StopList{index}
(6) Finally, document are made by default to PDF(pdflatex) format, but xesearch package must be compiled with the format PDF (XeTeX). Although simply View/export in this format could work with this MWE, it is better go to Document > Settings... > Fonts > Check "Use non-TeX fonts", so it will be compiled by default with XeTeX
And that is all. Without hyperref, with Ctrl-R, you will see in the second page:
As you see, "PCR" was added automatically. So it works. The generated source code, should be:
%% LyX 2.3.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage{fontspec}
\usepackage{makeidx}
\makeindex
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xesearch}
\SearchList{index}{#1\index{{#1}}}{ELISA,PCR}
\makeatother
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\begin{document}
\index{ELISA} and PCR
\StopList {index}
\printindex
\end{document}
- 80,769


