Wednesday, July 27, 2011

Create Glossary in LaTeX

** I have been able to create it using MAC, but NO UBUNTU** This is what I have done:

From Wikibooks:
\usepackage{glossaries}
\makeglossaries
Important: It must be loaded AFTER the hyperref package (contrary to the general advice that hyperref should be loaded last).


to NOT having the page number on the glossary page:  
??? - GOogLe -
 

and at where I want it to be printed:
\printglossaries

2 ways to define a glossary term:
 - long way:
\newglossaryentry{U}   % the label
{name={universal set}, % the term
 description={the set of all things} % a brief description
 symbol={\ensuremath{\mathcal{U}}}  % the associated symbol 
}


- short way:
\newacronym[<key-val list>]{<label>}{<abbrv>}{<long>}
 


This is from the introduction to glossaries file.
In order for a term to appear in the document, it must have been used:
\gls{<label>}
which will print the term associated with <label>.
If the hyperref package has also been loaded, the term will also by hyperlinked to the relevant entry in the glossary.

\glspl{<label>}
print the plural of the term associated with <label>.

\Gls{<label>}
\Glspl{<label>}
convert the first character to upper case.

 Important: Don't use these commands in moving arguments, such as those used by \chapter, \section and \caption

 In order for the glossary to appear, one has to use the terminal. Say the document is myDoc,
1. Build the LaTeX document as usual: using editor, or the command
latex myDoc
in the terminal.

2. This is the crutial step, type
makeglossaries myDoc
if you have Perl installed. Note: Macbook has it.

3. Build the LaTeX document once more. The glossary is now included! (Phew)

I think for each new change in the glossary one has to repeat step 2 and 3.
Also, if one has a glossary that has not appear in the main file but still wants it to appear in the glossary, will need to repeat Step 2 and 3.

The appearance of the glossary depend on the glossary style in use. Default: "description" environment. These are described in section 15 of the main glossary file.

To create a separate file for glossary, see section 4.3. Loading Entries From a File in the complete user manual. In short, one can store all the entry in a file, say myGlossary.tex, then use
 \loadglsentries[<type>]{myGlossary}


-----------------------------------------------------------------------------
The above post works for Mac. Things turns out to be a lot more complicated if you are using Ubuntu (or switching to Ubuntu like I did)

Here is a detail instruction on how to have the package installed, the command work in terminal, and moreover, how to add it to Kile.

Note that, in order to follow it, you need to know how to open a folder as root,
and how to add link to PATH.

More precisely, in steps 7, I choose
makeglossaries, '%S', and everything else as he suggested.

my working heading is:
\usepackage{glossaries}
\makeglossaries
\loadglsentries{glossary}

-------------------------------------------------------------------------------------------
Note that, at first I forgot to remove [xindy] in
\usepackage[xindy]{glossaries}
so when it comes to compile the file, it asks that I have the xindy package installed. I found it in http://packages.ubuntu.com/natty/amd64/xindy/download along with a list of prerequisite packages. They recommend me to add the package source with the link
deb http://ubuntu.mirror.cambrium.nl/ubuntu/ natty main universe
After I did it, the synaptic package manager starts downloading a lot of packages information. Then I got the error

Reading package lists... Error!
E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Limit. Current value: 25165824. (man 5 apt.conf)
E: Error occurred while processing tintii (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/ubuntu.mirror.cambrium.nl_ubuntu_dists_natty_universe_binary-i386_Packages
W: Unable to munmap
E: The package lists or status file could not be parsed or opened.

and it stops working. Now I dont know what to do in order for my synaptic package manager works again :(

Update: By using the steps in https://help.ubuntu.com/community/SynapticHowto, specifically,
System - Administrator - "Software Sources"
then remove the added source list, I have been able to revert everything. Few!

Notice that, the command with [xindy] works fine with Mac.

----------------------------------------------------------------------------------------------------------------------

The link to an introduction to using glossaries and a complete user manual from CTAN website.

A detailed instruction is here
From CTAN website: documents
Article on the glossary package on the Latex community.

Monday, January 24, 2011

Add hyper link to Latex documents - Use hyperref

From Wiki: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks
From Sebastien Latex's tricks: http://merkel.zoneo.net/Latex/index.php
From the manual: http://mirror.switch.ch/ftp/mirror/tex/macros/latex/contrib/hyperref/doc/manual.html#x1-50003.1

Basically, if you don't need to go heavy on the specific options,
Just load the package in the preamble, at the end of all the other packages but prior to other settings:

\usepackage{hyperref}