LyXCustomizing an index with Lyx

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
techwriter
Posts: 4
Joined: Sat Apr 06, 2013 12:28 am

Customizing an index with Lyx

Post by techwriter »

Is there an easy way to alter the layout of the index when using Lyx? I just want to change the number of columns from 2 to 3. Thanks!

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

Customizing an index with Lyx

Post by cgnieder »

Hi techwriter,

Welcome to the LaTeX community.

It is actually quite easy with the imakeidx package by Enrico Gregorio. Just add

Code: Select all

\usepackage{imakeidx}
\makeindex[columns=3]
to the document preamble (via Document > Settings > LaTeX preamble).

Regards
site moderator & package author
techwriter
Posts: 4
Joined: Sat Apr 06, 2013 12:28 am

Re: Customizing an index with Lyx

Post by techwriter »

Wow, thank you! I used your example code, and it worked.

I noticed that Lyx was originally willing to start the index on an even-numbered page (the left side of a book), but after using imakeidx, it will insert a blank page so that the index starts on an odd-numbered page. Is there any way to disable the page insertion? Thanks again.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Customizing an index with Lyx

Post by cgnieder »

techwriter wrote:I noticed that Lyx was originally willing to start the index on an even-numbered page (the left side of a book), but after using imakeidx, it will insert a blank page so that the index starts on an odd-numbered page. Is there any way to disable the page insertion?
Yes: add \indexsetup{noclearpage} after \usepackage{imakeidx}. You may want to have a look at the imakeidx documentation for all options and possibilities.

Regards
site moderator & package author
techwriter
Posts: 4
Joined: Sat Apr 06, 2013 12:28 am

Customizing an index with Lyx

Post by techwriter »

I inserted the \indexsetup{noclearpage} command, so that part of the preamble looks like this:

Code: Select all

\usepackage{imakeidx}
\makeindex[columns=3]
\indexsetup{noclearpage}
But the program still inserts a page after the appendix and then prints the index (I have only 1 index). The "noclearpage" setting didn't seem to have any effect. Perhaps I am doing something wrong?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Customizing an index with Lyx

Post by cgnieder »

techwriter wrote:[...] the program still inserts a page after the appendix and then prints the index (I have only 1 index). The "noclearpage" setting didn't seem to have any effect. Perhaps I am doing something wrong?
Difficult to say... perhaps you can attach a sample document which shows this behaviour?

Regards
site moderator & package author
techwriter
Posts: 4
Joined: Sat Apr 06, 2013 12:28 am

Customizing an index with Lyx

Post by techwriter »

I created a sample document and just copied the source. The sample has three pages of text and then an index. A blank page is inserted before the index despite the use of "noclearpage."

Code: Select all

\RequirePackage{fix-cm}
\documentclass[12pt,english]{book}
\usepackage{fourier}
\usepackage{helvet}
\renewcommand{\ttdefault}{cmtt}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=0.5in,bmargin=0.5in,lmargin=0.5in,rmargin=0.5in}
\setcounter{secnumdepth}{5}
\setlength{\parskip}{\bigskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{makeidx}
\makeindex

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\usepackage{enumitem}		% customizable list environments
\newlength{\lyxlabelwidth}      % auxiliary length 
\numberwithin{table}{section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{imakeidx}
\makeindex[columns=3]
\indexsetup{noclearpage}

\makeatother

\usepackage{babel}
\begin{document}
blah\index{blah}

\newpage{}

halb

\newpage{}

halb

\printindex{}
\end{document}
Sorry about all of the commands at the beginning of the sample, but I thought one of them might be causing the problem, so I included them.
Post Reply