1

Note: This question differs from other similar custom-list questions because each of my environments-of-interest can have multiple keywords, and I only want to generate a list pertaining to one keyword at a time.

In my dissertation's appendix I'm including PDFs via \includegraphics. These PDFs are questions I've administered to students. There are dozen of these questions. Some were administered multiple times in different quarters to different students. For example, question version 35 might be administered in spring 2011 and autumn 2013, and summer 2014. In the caption of each figure I'll include the quarter(s) in which it was administered.

However, I want to also provide for the reader a list of figures that are sorted by quarter. For example, I want the reader to see a list of all the questions administered in spring 2011. The tricky part is I want to have this automated in some way.

Can I somehow include a keyword like spring-2011 inside all of my \begin{figure} environments corresponding to a particular quarter, and then automatically generate a list of figures that contain a given keyword?

This list should automatically pull only the figures that have a certain keyword (and each figure itself can have multiple keywords).

If it makes any difference, I want to include this list of figures in the appendix itself. And I would prefer to be able to easily customize the formatting/look of the list.

So here's what I want to be able to do:

\documentclass{book}
\usepackage{graphicx}

\newcommand{\makeMyCustomQuarterList}[2]{
    %#1 = quarter tag, e.g. "winter-2013"
    %#2 = title of custom list, e.g. "Winter 2013"
    %
    %How do I implement this?
    %
    }

\newcommand{\questionQuarterTag}{ %This is placed inside \figure environments 
    %How do I implement this?
    }

\begin{document}

\chapter{A chapter}
Here's the body of the document. Pretty short, eh?


\appendix
\chapter{An appendix}

Each question administered to students is included only once.
The quarters it which each question was administered are found in the corresponding captions.
For convenience, a list of questions organized by quarter is included here:

% Produce list of questions administered in winter 2013
\makeMyCustomQuarterList{winter-2013}{Winter 2013}

Maybe I want text here.

% And other list for spring 2013:
\makeMyCustomQuarterList{spring-2013}{Spring 2013}

%The above \makeMyCustomQuarterList commands should produce two separate
% mini-tocs, each of which looks like:

%Questions administered in #2
%Figure A.1 ................ pg. 34
%Figure A.5 ................ pg. 38
%Figure A.6 ................ pg. 39


% Here is one of the questions that I want to tag with a quarter.
\begin{figure}
    \rule{5in}{7in}
    \caption{Administered in quarters X, Y, and Z}
    \label{myfig}
    \questionQuarterTag{winter-2013}
    \questionQuarterTag{winter-2014} %Note multiple tags!
\end{figure}

\end{document}

After looking at @JohnKormylo's link in the comment below, I decided to implement an index from splitidx. I think this format will actually work better for the reader.

BMS
  • 915
  • 1
    See http://tex.stackexchange.com/questions/472/how-can-i-have-2-or-more-distinct-indexes-in-latex – John Kormylo Sep 15 '14 at 17:40
  • Do you mean an index or a list of contents? (figures then)? –  Sep 15 '14 at 18:18
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Sep 15 '14 at 18:20
  • @ChristianHupfer There's no MWE since I don't know how to do what I want to do. I'll add a non-working example that shows what I do want to do, though. – BMS Sep 15 '14 at 18:31

2 Answers2

1

The following code is not perfect yet but I think you can make it. I use float package to declare new floating environments. So whenever you say \questionQuarterTag{tpye}{coptain} it typesets a floating environment of type tpye and passes the caption coptain to the corresponding List of XXX.

\documentclass{article}
\usepackage{float}

\newcommand{\makeMyCustomQuarterList}[2]{%
    \listof{#1}{#2}}
\newcommand{\questionQuarterTag}[2]{
    \hrule height0pt
    \vbox to0pt{
        \vspace*{\paperheight}
        \begin{#1}
            \caption[#2]{}
        \end{#1}}}
\newfloat{win13}{H}{w13}\floatname{win13}{Winter 2013}
\newfloat{spr14}{H}{p14}\floatname{spr14}{Spring 2014}

\begin{document}
\makeMyCustomQuarterList{win13}{List of Winter 2013}
\makeMyCustomQuarterList{spr14}{List of Spring 2014}
\clearpage
\begin{figure}[H]
    \rule{1in}{1in}
    \caption{A Black box}
    \questionQuarterTag{win13}{Black}
\end{figure}
\begin{figure}[H]
    \rule{1in}{2in}
    \caption{A tall box}
    \questionQuarterTag{win13}{Tall}
    \questionQuarterTag{spr14}{Tall}
\end{figure}
\begin{figure}[H]
    \rule{2in}{2in}
    \caption{A tall fat box}
    \questionQuarterTag{spr14}{Tall and Fat}
\end{figure}
\end{document}
Symbol 1
  • 36,855
1

This approach, the index-like one, does not use multiple indexes. Instead, I use ! to assign subentries. At the beginning of the following code, \newkeyword{win13}{13-4}{Winter 2013} declares a key win13 sorted as 13-4 and shown as Winter 2013. While including figures, \questionQuarterTag{win13}{black}{Black} adds under win13 a subentry sorted as black and shown as Black.

\documentclass{article}
\usepackage{makeidx}
\makeindex
\newcommand*\newkeyword[3]{
    \expandafter\def\csname mykeyword#1sort\endcsname{#2}
    \expandafter\def\csname mykeyword#1name\endcsname{#3}}
\newcommand{\questionQuarterTag}[3]{
    \index{\csname mykeyword#1sort\endcsname @\csname mykeyword#1name\endcsname!#2@#3}}
\begin{document}
\newkeyword{win13}{13-4}{Winter 2013}
\newkeyword{spr14}{14-1}{Spring 2014}
\begin{figure}[H]
    \rule{1in}{1in}
    \caption{A black box}
    \questionQuarterTag{win13}{black}{Black}
\end{figure}
\begin{figure}[H]
    \rule{1in}{2in}
    \caption{A tall box}
    \questionQuarterTag{win13}{tall}{Tall}
    \questionQuarterTag{spr14}{tall}{Tall}
\end{figure}
\begin{figure}[H]
    \rule{2in}{2in}
    \caption{A tall fat box}
    \questionQuarterTag{spr14}{tallfat}{Tall and Fat}
\end{figure}
\printindex
\end{document}
Symbol 1
  • 36,855