I'm writing a document in which i talk about many URIs (inline). To not clutter readability too much, i'd like to define and use CURIEs instead (this is common in the Semantic Web community). So rather than talking about http://dbpedia.org/resource/Dog i'd like to talk about dbr:Dog.

Currently i have some code like this in my preamble:

  \expandafter\newcommand\csname#1\endcsname[1]{{\curiesize \href{#2##1}{\nolinkurl{#1:##1}}}}%

So in the document i can then write something like \dbr{Dog} to refer to dbr:Dog.

As the list above gets longer and longer i'd like to extend the \defcurie meta-command to somewhere remember the CURIE prefixes and later print a glossary like listing in the front- or backmatter.

Any recommendations how to do that?


Fiddling around with this some more, i found a first way to solve this myself by extending the preamble meta-command like this:

\newcommand{\usedprefixes}{} % used to store `prefix: & \url{uri} \\` like table rows
  \expandafter\def\expandafter\usedprefixes\expandafter{\usedprefixes\texttt{#1}: & \begin{small}\url{#2}\end{small} \\[1ex] }
  \expandafter\newcommand\csname#1\endcsname[1]{{\curiesize \href{#2##1}{\nolinkurl{#1:##1}}}}%

Then later in the document do something like this:

\chapter*{List of URI Prefixes (CURIEs)}

Still interested in better/cooler approaches though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.