# Custom “list of” command for lab notebook

I'm keeping my lab notebook for my PhD in LaTeX. I have it set up such that each "project" has its own chapter.

When I make a new entry into the notebook I use a custom "entry command":

\newcommand{\entry}[2]{%
\marginnote{#1}%
}


where the first field is the date and the second is a brief explanation of what the entry is about, e.g.

\entry{2015-04-08}{Information on geospatial data}


Is there a way to make a "list of" feature for the "entry" command that is separated by chapter such that I can get a quick overview of what and when I did a certain task/experiment without having to dive into the document? This would include field #1 and #2.

Or is there a better way to set this up? I would prefer use a command if possible, and not have to switch to an environment.

• May be you can use todonotes... – user11232 Apr 8 '15 at 15:30
• Could you give some feedback, please? ;-) – user31729 Apr 9 '15 at 20:53

Something like this?

I used the standard book class, modified the 'appearance (but not the logic of \entry and the tocloft package to make automatic entries to a .lab file, containing the date and the note.

This is typeset using various \cft..... commands provided by tocloft.

Additionally, there is an empty separating line after each chapter in the \listoflabentries output.

\documentclass{book}

\usepackage{xpatch}
\usepackage{tocloft}
\usepackage{tcolorbox}
\usepackage{marginnote}

\newcommand{\listoflabentriesname}{List of Entries}
\newlistof[chapter]{labentries}{lab}{\listoflabentriesname}
\setlength{\cftlabentriesnumwidth}{3cm}

%%% no dots
\renewcommand{\cftlabentriesdotsep}{\cftnodots}

%% Stolen for tocloft documentation
\newlength{\mylen}
\setlength{\mylen}{0.5em}
\renewcommand{\cftlabentriespresnum}{\hfill} % note the double l'
\renewcommand{\cftlabentriesaftersnum}{\hspace*{\mylen}}

\newcommand{\entry}[2]{%
\refstepcounter{labentries}
\marginnote{#1}
\begin{tcolorbox}[colback=yellow]
#2
\end{tcolorbox}
\renewcommand{\thelabentries}{\bfseries #1}
% Adding the entry to the \jobname.lab file
}

\makeatletter
\xpatchcmd{\@chapter}{%
}{\typeout{Patch success}}{}
\makeatother

\begin{document}

\listoflabentries

\chapter{First}
\entry{2015-04-08}{Information on geospatial data}

\chapter{Second}
\entry{Stardate 5934}{Captain's log: Data becomes sillier every day}
\entry{Stardate 5934.6}{Captain's log: Date with Dr. Beverly Crusher quite disappointing. Don't know what to do now}

\end{document}


• This is a quick hack (out of nothing), more improvement later on (perhaps) – user31729 Apr 9 '15 at 1:39
• Thanks! This nearly works for me, I'm getting some errors which seem to be causing there to be no separation for each chapter. Ideally I'd like to get the \listoflabentries at the beginning of each chapter, so that they are more explicit to each part of the notebook. This is a good start though, and I should be able to get a better idea of where to head from here. – chasely Apr 10 '15 at 0:13
• @chasely: If there would have an example to work with my idea would have been better too ;-) – user31729 Apr 11 '15 at 4:23
• Had a little bit of time to look at this today. Is there a way to combine this with the minitoc package? – chasely Apr 11 '15 at 19:59
• @chasely: Possibly, but minitoc is unmaintained for years. I like it too, but as written, unmaintained and endangered to become outdated. jfbu, a user here, wrote etoc`, with similar features – user31729 Apr 11 '15 at 20:04