Can someone with low-level LaTeX knowledge please help me create new customized commands? The commands should be named \storeitem and \typesetitems, and they should work like this:


some other stuff


This is what the commands should do:

  1. On first run of LaTeX, the \storeitem commands should put their arguments into an auxiliary file, in this case "hello" and "world".
  2. Each instance of \typesetitems (which is assumed to occur the equal number of times as the \storeitem command - twice in the above example) should put all the stored items in a regular bulleted list (itemize) with a normal font, with the exception that the N-th occurrence of \typesetitems should typeset the N-th item in an italic font.

Thus, the results of the above commands would be something like:


A few other things that should be included if possible, for more friendliness and robustness:

  1. If the number of occurrences of \storeitem and \typesetitems don't match, produce a warning. (And do something graceful with the "overflowing" commands, which could be either of them.)

  2. If one edits the arguments of existing \storeitems, adds new \storeitems, or deletes existing \storeitems, produce some kind of a "Labels changed, run again" warning message. (Similar to the one that LaTeX does by default when labels have changed.)

  3. Maybe later I may not want itemize. Maybe I want numbered lists. Or maybe I do not want lists at all. And maybe I want to do something other to the N-th item than italicize it. For these reasons, it should be rather straightforward to edit the custom commands to suit one's needs.

  • 1
    why have \typesetitems\storeitem{world} and worry about not having the commands in pairs rather then just having \storeandtypesetitem{world} which does both jobs. printing the whole list but italicising the current one. Oct 6 '12 at 22:11

The following stores the items in references (item1, item2, item3, …) in the .aux file. And the last number is remembered in reference itemlast. \typesetitems sets the items in environment itemize getting the stored items from references item1 up to item<itemlast>. Two counters are used, storeitem counts the stored items and typesetitems the number of \typesetitems. If at the end of document the two counters differ, a warning is given.


      Mismatch store/typeset items:\MessageBreak
      \string\storeitem: \the\value{storeitem}\MessageBreak
      \string\typesetitems: \the\value{typesetitems}%
  \ifnum\zref@extractdefault{itemlast}{default}{0}>0 %
      \count@=0 %
      \advance\count@ by\@ne


some other stuff



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.