4

I am new at LaTeX. My question is why this code doesn't work.

\documentclass[a4paper,12pt]{article}

\usepackage{fullpage} 

 \newcounter{const}
 \renewcommand{\theconst}{\roman{const}}

 \renewcommand{\item}{\stepcounter{const} (\theconst)}
 \newcommand{\myitem}{\item}

\newenvironment{myenumerate}
{ \begin{itemize} }
{ \end{itemize} }

\begin{document}

\begin{myenumerate}
   \myitem A
   \myitem B
   \myitem C
\end{myenumerate}

\end{document}
  • Are you just interested in a list that prints its items using (i), (ii), (iii), ...? Should it look like a regular list? – Werner Jun 6 '17 at 6:57
  • you have redefined \item are you sure you want to redefine that? this is used in the following environments none of which would work now, enumerate, itemize, description, verbatim, center, quote, ... – David Carlisle Jun 6 '17 at 6:59
  • 1
    Probably the answer to this post: tex.stackexchange.com/q/54055/101651 could help you. – CarLaTeX Jun 6 '17 at 7:03
4

The issue is that \item does more than just print the items within the list. Specifically, it sets a flag to identify that you've provided at least one \item within any list (amongst other things). Redefining \item in the way you did removes this functionality and therefore throws an error under the regular list environment (myenumerate in your example emulates a regular enumerate list).

If all you're after is an enumerated list using \roman numbers, then you can use enumitem:

enter image description here

\documentclass{article}

\usepackage{enumitem}

\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate,1]{label = (\roman*)}
\newcommand{\myitem}{\item}

\begin{document}

\begin{myenumerate}
 \myitem A
 \myitem B
 \myitem C
\end{myenumerate}

\end{document}

This can also be changed to print an inline list, as well as a host of other modifications.

| 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.