I have a document (article) presenting a list and description of several tasks. Each task is written in either a section or subsection, beside the title and description it includes the name of the person in charge, just in plain text in the beginning of the (sub)section. The name can be present in more than one (sub)section, as one person may have multiple tasks.

The end document looks something like this:

1. Basics
1.1 Task A
Name: John Doe
The task is about ...
It needs to be completed by July 2012.

1.2. Task B
Name: James F.

2. Task C
Name: John Doe

and so on.

In the beginning of the document I would like to generate a table (or index) of the involved people and the tasks for which they are responsible (i.e. where all the occurrences of the names are referenced in one place), in order to have an organised view in which I could see all assigned tasks for a person, and it should be in the following format:

Name     | Task         | Section, page

John Doe | Task A       | 1.1, p. 2
         | Task C       | 2, p. 5
James F. | Task B       | 1.2, p.3

Is there an easy solution for that?

The solution should facilitate that each person could be easily switched to another task, so that the index is automatically regenerated.

I don't think I can really use labels here, as one name can appear multiple times.

Indexing, like this:

\subsection{Task A}
Name: John Doe \index{John Doe}
The task is about ...
It needs to be done by ...

Gives me a basic result:


John Doe, 2, 5

It might be a good place to start, but as far as I know, changing the layout of the index in a table (which also includes section names) is a pain.

  • What are you asking? Is this a question about how to make an index? In which case the above link should give you your answers. Or is this a more specific question about how to format the index in the above way? Could you make this clearer? – Seamus May 9 '12 at 10:23
  • Thanks. This is a specific question about how to format the index in the presented way. However, I never worked with indexing, so I'll take a look in the link you had provided me, but I would appreciate if you could could briefly give me the answer for the complete solution. – 528 May 9 '12 at 10:42
  • Okay, I read the resource, and I indexed all the names in the document and compiled an index. However, now I have the usual index: name, page number. How do I format it to the above table? And also print the (sub)section in which the index appears? – 528 May 9 '12 at 12:53
  • 1
    Maybe you should edit your question to make it clearer what you are asking, and what you have done so far. Perhaps include a small example that demonstrates what you want. – Seamus May 9 '12 at 14:07

Here is an approach with LuaLaTeX without any LaTeX indexing. The main principle is to store all needed informations in a Lua table during the LaTeX run and print the (sorted) informations at the end of the document. To get the section name I used the \sectioningtitle macro of lockstep (Thank you!).


--global table
names = {}

function storeItems(name, section, task, page)
    --create a new name item
    item = {}
    item.Name = name
    item.Section = section
    item.Task = task
    item.Page = page

    --add the new name item to the table
    table.insert(names, item)

function printTable()
    --sort the table (Name order)
    table.sort (names,
           function (item1, item2)
             return item1.Name < item2.Name

    --print the latex table
    tex.print(string.format(" Name & Section & Task & Page\\\\\\hline"))

    local nameTemp = ""

    for i,p in ipairs(names) do
        --print the name only if it is a new one
        if p.Name == nameTemp then
            tex.print(string.format("     & {%s} & {%s} & {%s}\\\\",p.Section, p.Task, p.Page))
            tex.print(string.format("{%s} & {%s} & {%s} & {%s}\\\\",p.Name, p.Section, p.Task, p.Page))

        nameTemp = p.Name


% read the external lua file to declare the defined function,
% but without execute the Lua function

% latex command to execute the lua function
\def\store#1#2#3#4{\directlua{storeItems("#1", "#2", "#3", "#4")}}

% command for the references

%this is used to get the current sectionname


\section{ Basics}

\subsection{Task A}
Name: \myRef{John Doe}\\
The task is about ...\\
It needs to be completed by July 2012.

\subsection{Task B}
Name:  \myRef{James F.}

\subsection{Task C}
Name: \myRef{John Doe}
\end{document} `enter code here`

enter image description here

|improve this answer|||||

Here's a partial solution -- I didn't manage to add sectioning numbers plus a "table-like" header to the index, but I managed to create an index of persons and the tasks they're responsible for.

  • Define a new \sectioningtitle macro which is empty at the start.

  • Patch the internal \@sect macro so that every time you start a section/subsection, its argument also becomes the new meaning of \sectioningtitle.

  • Define a new \taskindex macro which

    • typesets "Name: " plus its argument (this is just for convenience);

    • adds an index entry with its argument as main item and the current meaning of \sectioningtitle as subitem. (Note: In the following MWE, I assume that MakeIndex is run using the standard ! as item/subitem separator.)



\usepackage[unbalanced]{idxlayout}% no page break before `article` index




\newcommand*{\taskindex}[1]{Name: #1\index{#1!\sectioningtitle}}



\subsection{Task A}

\taskindex{Doe, John}

\subsection{Task B}

\taskindex{F., James}

\section{Task C}

\taskindex{Doe, John}



enter image description here

|improve this answer|||||

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.