hyperlinks and alphabetized lists in latex

There are so many things to learn and not quite as many ways to record what it is you’ve learned. There’s not many things more frustrating than the feeling “I knew a thing some time ago, but now I’ve forgot” and feeling helpless to ever get it back. For this reason I’ve resolved to do a better job documenting what I’ve learned and been working on. That’s what this blog is all about, but a blog isn’t the best place for mathematics or keeping track of citations. It also doesn’t seem natural to make a printout of a blog either. But getting word processor features into LaTeX is a chore sometimes.  Below are how to put hyperlinks into latex documents and also how to create alphabetized lists in latex.  For me I want alphabetized lists to make a reference sheet for myself and hyperlinks so that I can seamlessly access my references as I’m reading.

\usepackage{hyperref}

hyperref is the standard for adding hyperlinks to a pdf, and it’s super easy.  You can make internal links to within the pdf:

we use \hypperref[mainlemma]{lemma \ref*{mainlemma}}

\usepackage{hyperref}

or you can link to outside sources either displaying the actual site location or an alternate:

\url{http://www.wikibooks.org}
\href{http://www.wikibooks.org}{wikibooks home}

\usepackage{datatool}

the datatool example below can be taken directly into your tex editor and compiled to generate an alphabetized definition list.  Will definitely be good for making reference sheets.  I took it from this site on LaTeX community.  This is also a good example of the power of latex that shows what a little creativity could do.  Also datatool itself seems like a powerful method for reading in data or arrays to be displayed in the pdf.

\documentclass{article}

\usepackage{datatool}

\newcommand{\sortitem}[2]{%
  \DTLnewrow{list}%
  \DTLnewdbentry{list}{label}{#1}%
  \DTLnewdbentry{list}{description}{#2}%
}

\newenvironment{sortedlist}%
{%
  \DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}%
}%
{%
  \DTLsort{label}{list}%
  \begin{description}%
    \DTLforeach*{list}{\theLabel=label,\theDesc=description}{%
      \item[\theLabel] \theDesc
    }%
  \end{description}%
}

\begin{document}

\begin{sortedlist}
  \sortitem{banana}{A yellow fruit}
  \sortitem{pear}{An oddly shaped fruit}
  \sortitem{apple}{A roundish fruit}
\end{sortedlist}

\end{document}
This entry was posted in computing, LaTeX. Bookmark the permalink.

Comments are closed.