4

How would I use the Nomenclature to display a list of symbols sorted by the page number rather than symbol letter.

The code below was used to generate this List of Notations. However, I am trying to figure out how to sort by page number instead.

enter image description here

===

\documentclass[11pt,oneside,a4paper,onecolumn]{article}  
\usepackage[left=1.5in,top=1.25in,bottom=1.25in,right=1.25in,papersize={8.50in,11.00in}]{geometry} % Sets the proper margins.
\usepackage{amsmath, amssymb, amsthm,mathtools} % AMS packages
\usepackage{hyperref}
\usepackage{appendix}
\usepackage[refpage]{nomencl}
\renewcommand{\nomname}{List of Notations}
\renewcommand*{\pagedeclaration}[1]{\unskip\dotfill\hyperpage{#1}}
\makenomenclature

\usepackage{makeidx}
\makeindex

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Begin List of Notation Page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\phantomsection % Create a phantom section such that the 'List of Notation' may be properly added to the table of contents.
\addcontentsline{toc}{section}{List of Notation} 
\printnomenclature[1.5cm] % This command automatically generates the list of tables based on tables in the document.
\pagebreak[4]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% End List of Notation Page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\begin{equation*}
F=ma
\end{equation*}

$\nomenclature{$F$}{Force}
$\nomenclature{$a$}{Acceleration}

\pagebreak[4]

\begin{equation*}
E=MC^2
\end{equation*}

$\nomenclature{$E$}{Energy}
$\nomenclature{$M$}{Mass}
$\nomenclature{$c$}{Speed of Light}

\end{document}
1
  • 1
    Are you really sure? If you have only a few entries, then the sorting order doesn't really matter. If you have many, then how are readers supposed to find the symbol they're looking for in a long unordered list?
    – egreg
    Commented May 5, 2012 at 23:03

1 Answer 1

5

Not to contradict egreg (this is still an odd request), but since you asked, you can add an optional sort key to the nomenclature entries. Normally this is used for a few sort categories (uppercase Greek versus lowercase Greek versus acronyms versus ...), but you can make the page number the sort prefix:

\documentclass[11pt,oneside,a4paper,onecolumn]{article}  
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage[refpage]{nomencl}
\renewcommand{\nomname}{List of Notations}
\renewcommand*{\pagedeclaration}[1]{\unskip\dotfill\hyperpage{#1}}
\makenomenclature
\usepackage{lipsum}
\makeatletter
\newcommand{\nomentry}[2]{% to sort by pages
  \nomenclature[\two@digits{\value{page}}]{#1}{#2}%
} % Ref: https://tex.stackexchange.com/questions/30930/how-to-output-a-counter-with-leading-zeros
%\newcommand{\nomentry}[2]{% to sort normally
%  \nomenclature{#1}{#2}%
%}
\makeatother
\begin{document}
\printnomenclature[1.5cm]
\clearpage

\begin{equation*}
F=ma
\end{equation*}

\nomentry{$F$}{Force}
\nomentry{$a$}{Acceleration}

\clearpage

\begin{equation*}
E=MC^2
\end{equation*}

\nomentry{$E$}{Energy}
\nomentry{$M$}{Mass}
\nomentry{$c$}{Speed of Light}

\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum

Also, in some cases, \(m\ddot{x} + + k x = 0\)
\nomentry{$m$}{Mass (also)}
\nomentry{$k$}{Spring Stiffness}
\nomentry{$x$}{Displacement}
\end{document}

enter image description here

This has a limitation of not sorting properly past 99 pages, and you'll still be sorting each page by case-sensitive alphabet, rather than sequentially. I expect there's some way to integrate fmtcount with an arbitrary amount of zero-padding to fix the page limitation, but I've not figured that out yet.

2
  • 1
    One can define \three@digits: \def\three@digits#1{\ifnum#1<100 0\ifnum#1<10 0\fi\fi\number#1}
    – egreg
    Commented May 6, 2012 at 13:36
  • True. I hadn't wanted to write that sort of thing in explicitly, hoping there was something more semantic in using fmtcount, but it's probably not as big a difference as I first thought. Commented May 6, 2012 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .