TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up a list environment for typesetting a problem set. I'd like to be able to input something like the following:

\item First solution.
\item[2.2] Second solution.

and have it come out as:

Problem 1. First solution.
Problem 2 (2.2). Second solution

with the optional argument to \item being typeset in parentheses if it's present. I assume I should be able to \renewcommand{\makelabel} somehow, but I can't figure out how to do it. I can't get anything like the following to work:

\newcommand{\makepsetlabel}[1]{some if/then involving #1, checking if empty}

What's the right way?

share|improve this question
Welcome to TeX.sx! – egreg Feb 8 '13 at 22:59
up vote 5 down vote accepted

I would use a different command instead of \item:


  label=Problem \arabic*\protect\thispitem,
    \def\thispitem{ (#1).}%


\pitem First
\pitem[2.2] Second


In the label I add a command \thispitem (with \protect so enumitem doesn't interpret it when setting up the environment).

Then \pitem examines the presence of an optional argument and acts consequently: if none is specified, it just prints a period, otherwise a space, the parenthesized argument and the period.

enter image description here

share|improve this answer
Sounds like a good way to go -- thanks for the suggestion! – user25695 Feb 9 '13 at 13:31

One possibility is to grab the optional argument using your own command, so that \item does not see it.

\myitem abc
\myitem[2.1] def
share|improve this answer
The period will be in the wrong place. – egreg Feb 8 '13 at 23:07
@egreg --- Friday night is not the time to consider such details! – Ian Thompson Feb 8 '13 at 23:12
@IanThompson: I've added a deleted answer that could be used as a slight improvement(?) to your current definition. Grab some from it if you need it. – Werner Feb 8 '13 at 23:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.