LaTeX, memoir and a custom List Of URLs

is a neat thing. Sometimes, though, it’s damned hard to get what you actually thought would be cool in your book. That was precisely the case with me. Due to the fact that my book is quite abundant in pictures, I wanted to give the credit where it’s due and add appropriate source links. I didn’t want the source to be displayed under the picture itself – A nice List Of URLs, in a shape similar to ToC, LoT or LoF, preferably clickable URIs. I wasted a week trying to figure out how to do it. As  noob as I am it was still non trivial. I decided I wanted to share the secret arcane knowledge about this with other adepts of  .

Assuming that we have the following in the preamble:


\documentclass[ebook,12pt,oneside,onecolumn,final]{memoir}

\usepackage[greek,english,polish]{babel}

\usepackage[linktocpage=true]{hyperref}

\usepackage{tocloft}

we declare new counter and new list of:


\newcounter{mojezrodla}

\newcommand{\listzrodlaname}{Source list}

\newlistof{mojezrodla}{mzr}{\listzrodlaname}

\newcommand{\zrodlo}[1]{%

\refstepcounter{mojezrodla}

\addcontentsline{mzr}{mojezrodla}

{\protect\numberline{\thechapter.\themojezrodla}#1}\par}

And below our pictures we add accordingly


\zrodlo{\href{here_goes_the_url}{here_goes_the_label}}

so for instance:


\zrodlo{\href{http://www.google.com}{www.google.com}}

After compilation a new mzr file containing all the URL entries defined is being created and in the document in the place we write \mojezrodla we get a nice toc-like list of clickable URLs…well, sort of. The list is there, but it’s typography and/or formatting just sucks. What we need to do is to let the processor apply to the new list the same typography that is being used for toc or list of figures. In the preamble (below the previous definition) we add:


\makeatletter

\let\l@mojezrodla\l@figure

\makeatother

and voilà, perfect list of URLs is there. In case we really need it we have some possible customization to apply: – if you want to have the source printed below the image, in the place where you put


\zrodlo{\href{here_goes_the_url}{here_goes_the_label}}

\newcommand{\zrodlo}[1]{%

\refstepcounter{mojezrodla}

\par\noindent\textbf{Source \themojezrodla. #1}

\addcontentsline{mzr}{mojezrodla}

{\protect\numberline{\thechapter.\themojezrodla}#1}\par}

You can also play with the counter part:


\thechapter.\themojezrodla

or if you want the ‘per chapter’ numbering of URIs, define the counter in the following way:


\newcounter{mojezrodla}[chapter]

Hope this helps. I certainly needed that and couldn’t find any comprehensive example of how to achieve what I want.

Advertisements

Nocturnal primate - dumb as I am now it used to be worse.

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: