3

I need to create the following output

1. [J1] bla bla bla
2. [J2] bla bla bla
....
13. [J13] bla bla bla
14. [C1] bla bla bla
15. [C2] bla bla bla
...
21. [B1] bla bla bla

Is there anyone who has ideas how to get it?

closed as unclear what you're asking by user31729, Mensch, Werner, user36296, Mico Aug 5 '16 at 18:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

3

This also copes with references. You're not required to have \item outside subenumerate, they're added just by way of example.

\documentclass{article}

\makeatletter
\newcounter{enumz}
\newenvironment{bienumerate}
 {\enumerate\setcounter{enumz}{0}\let\item\bi@item}
 {\endenumerate}
\newenvironment{subenumerate}[1]
 {\setcounter{enumz}{0}\def\bi@prefix{#1}}
 {}
\let\ltx@item\item
\newcommand{\bi@item}{%
\@ifundefined{bi@prefix}
    {\ltx@item}
    {\stepcounter{enumz}\ltx@item\relax
     \protected@edef\@currentlabel{%
       \@currentlabel~% <----------- comment this if you don't want the item number in the \ref
       [\bi@prefix\theenumz]%
     }%
     [\bi@prefix\theenumz]~}%
}
\makeatother

\begin{document}

Test of reference: \ref{test}.

\begin{bienumerate}

\item bla bla bla

\begin{subenumerate}{J}
\item\label{test} bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\end{subenumerate}

\begin{subenumerate}{B}
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\item bla bla bla
\end{subenumerate}

\item bla bla bla

\begin{subenumerate}{C}
\item bla bla bla
\item bla bla bla
\item bla bla bla
\end{subenumerate}
\end{bienumerate}

\end{document}

enter image description here

If you comment the marked line, the reference line will be like

enter image description here

2

Something like this?

enter image description here

\documentclass{article}

\usepackage[inline]{enumitem}

\newlist{inlinelist}{enumerate*}{1}


\newcommand{\inlineformat}[1]{%
  [#1]%
}

\setlist[inlinelist,1]{font={\bfseries},label*={\arabic*}}
\begin{document}

\begin{inlinelist}[label*={\inlineformat{J\arabic*}}]
\item Foo
\item Foobar
\end{inlinelist}

\begin{inlinelist}[label*={\inlineformat{C\arabic*}}]
\item Foobar
\item Foo
\item Otherstuff
\end{inlinelist}

\end{document}
1

It all depends on how you want to specify the syntax. The simplest way would be to define commands that differ from your regular \item-like list:

enter image description here

\documentclass{article}

\newcounter{numchar}
\newcommand{\numchar}{}
\newcommand{\setnumchar}[1]{%
  \renewcommand{\numchar}{#1}% Update \numchar
  \setcounter{numchar}{0}}% Reset numchar counter
\newcommand{\nextitem}{%
  \item \relax\stepcounter{numchar}[\numchar\thenumchar]~\ignorespaces}

\begin{document}

\begin{enumerate}
  \setnumchar{J}
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla

  \setnumchar{C}
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla

  \setnumchar{B}
  \nextitem bla bla bla
  \nextitem bla bla bla
  \nextitem bla bla bla
\end{enumerate}

\end{document}

Above I've defined \nextitem to act like an \item with some added content. The added content matches your requirement, as laid out by \setnumchar - a macro that updates the inner enumeration character as well as resets the inner enumeration.


If you wish to maintain the \item-like usage, you can use the following updated definition of \setnumchar:

\documentclass{article}

\newcounter{numchar}
\newif\iffirstset
\newcommand{\numchar}{}
\newcommand{\setnumchar}[1]{%
  \renewcommand{\numchar}{#1}% Update \numchar
  \setcounter{numchar}{0}% Reset numchar counter
  \iffirstset\else
    \firstsettrue
    \let\olditem\item
    \renewcommand{\item}{%
      \olditem\relax\stepcounter{numchar}[\numchar\thenumchar]~\ignorespaces}%
  \fi
}

\begin{document}

\begin{enumerate}
  \setnumchar{J}
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla

  \setnumchar{C}
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla

  \setnumchar{B}
  \item bla bla bla
  \item bla bla bla
  \item bla bla bla
\end{enumerate}

\end{document}

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