I'm trying to write a Tex command that automatically prints out attribution information for images I use in my document. I created 2 different commands. The first one is \nounattr
(with 3 parameters) which takes the image's name, the author and the link of the image. The second command is \printnounattrs
which has no arguments, but should simply print a list of all attributions added before using \nounattr
. I was able to implement these commands and get a simple list, but I cannot add any styling to the list whatsoever.
This is what I have at the moment:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nounattr}[2018/01/03 The noun project attribution]
\RequirePackage{svg}
\RequirePackage{url}
\newcommand\printnounattrs{}
\newcommand\nounattr[3]{\edef\printnounattrs{\printnounattrs#1 pictogram werd ontworpen door #2 van The Noun Project, onder de Creative Commons license (CC BY 3.0). Zie #3. }}
An MWE is the following:
\documentclass{report}
\usepackage[left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage[parfill]{parskip}
\usepackage{nounattr}
\begin{document}
\nounattr{Protein}{Ben Markoch}{https://thenounproject.com/search/?q=protein\&i=54837}
\nounattr{Peptides}{Fredrik Edfors}{https://thenounproject.com/search/?q=peptide\&i=66903}
\printnounattrs
\end{document}
I would however like to add some styling into the edef in order for #1 pictogram
to be printed italic and that the url is propely defined as a url using \url{#3}
. I changed \nounattr
to be:
\newcommand\nounattr[3]{\edef\printnounattrs{\printnounattrs\textit{#1 pictogram} werd ontworpen door #2 van The Noun Project, onder de Creative Commons license (CC BY 3.0). Zie \url{#3}. }}
But this gives me a undefined control sequence
error. I don't understand what's happening and how I can possibly fix this?
\textit
are not expandable, which means that they can't be used in an\edef
context. There are many questions about this concept on this site, for example tex.stackexchange.com/q/35039/35864 and linked questions. – moewe Jan 4 at 9:17etoolbox
orexpl3
instead. I think they can usually deal with these things as they don't go full\edef
on the contents. – moewe Jan 4 at 9:21\def
as it causes TeX to go out of memory for some reason. I will take a look at the list implementations you mentioned :) – Pieter Verschaffelt Jan 4 at 9:22\def
suggestion from my comment. – moewe Jan 4 at 9:23\expandafter\def\expandafter\printnounattrs\expandafter{\printnounattrs
instead of\edef\printnounattrs{\printnounattrs
– moewe Jan 4 at 9:25