2

How can I parenthesize the item numbers in enumerate when I am manually entering them? Here's a MWE:

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
\item[25-1] Compute $1 + 1$
\item[25-8] Compute $1 \times 1$
\end{enumerate}

\end{document}

I would like for it to display (25-1) and (25-8) automatically, i.e. I don't want to have to manually enter the parentheses every time.

2

I'm a little confused by this question, this appears to work fine?

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
\item[(25-1)] Compute $1 + 1$
\item[(25-8)] Compute $1 \times 1$
\end{enumerate}

\end{document}

If you clarify, I'll take another look at it...


enumitem doesn't seem to have an option for this built in because the brackets override the formatting, so here's a bit of a workaround that works:

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\newcommand{\pitem}[1]{\item[(#1)]}

\begin{enumerate}
\pitem{25-1} Compute $1 + 1$
\pitem{25-8} Compute $1 \times 1$
\end{enumerate}

\end{document}

Just replace all \item commands with the \pitem command.

1
  • As in, automatically add the parentheses. I'll make the appropriate edit. – user217285 Sep 29 '16 at 8:13
1

It is currently set up to only auto-add parens if the optional argument is used. That could be easily modified (for example, adding [label={(\arabic*.)}] after the \begin{enumerate}).

\documentclass{article}
\usepackage{enumitem}
\let\svitem\item
\renewcommand\item[1][\relax]{\ifx\relax#1\relax\svitem\else\svitem[(#1)]\fi}
\begin{document}
\begin{enumerate}
\item Normal item
\item[25-1] Compute $1 + 1$
\item[25-8] Compute $1 \times 1$
\item Another normal item
\end{enumerate}
\end{document}

enter image description here

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.