2
\newenvironment{resumelist}[1]
  {{\noindent\normalfont\bfseries #1}

   \list{}{\labelwidth\z@ 
        %% what's the meaning of the command \list{}
           \leftmargin 4\ccwd  
           \itemindent -2\ccwd   
           \listparindent\itemindent}%  
   \item\relax}

% what's the meaning of the command \item and what is the function of \relax

  {\endlist} %%why not \end{list}
David Carlisle
  • 757,742

1 Answers1

2

This idiom is used for lots of standard latex environments such as center and quote. They are one-item lists, like enumerate so

\list is the basic list constructor that makes enumerate or itemize but as there is just one item (the content of the environment) \item is supplied and the \relax does nothing but prevents \item looking ahead and treating a [ at the start of the text as an optional argument.

egreg
  • 1,121,712
David Carlisle
  • 757,742
  • Thank you very much Dr. Carlisle for you kind reply, I am still unclear, could you tell me where can I find the explanation of \list, I searched almost two days on the internet about this command, but find nothing useful explanation, meanwhile, can you explian why not using \begin{list} and why this environment ends up with \endlist, why not \end{list}? – Peter Yang Apr 02 '22 at 17:23
  • @PeterYang texdoc source2e will give you the documented sources of latex. Using \foo \endfoo is an optimisation common when defining one environment in terms of another. \newnvironment{abc}{}{} defines \abc and \endabc so you can call them directly in some contexts – David Carlisle Apr 02 '22 at 17:26
  • @PeterYang https://tex.stackexchange.com/questions/332063/understanding-list-and-item/332067#332067 – David Carlisle Apr 02 '22 at 17:29
  • \newenvironment{resumelist}[1] {{\noindent\normalfont\bfseries #1}

    \begin{list}{}{\labelwidth\z@ %% what's the meaning of the command \list{} \leftmargin 4\ccwd
    \itemindent -2\ccwd
    \listparindent\itemindent}%
    \item\relax} {\endlist}

    – Peter Yang Apr 02 '22 at 18:12
  • @PeterYang that comment just repeats the question, it sets the left margin to 4 times the command \ccwd which will be a length defined somewhere in code you have not shown. and the indent for the first line of text is set to -2 times that length (ie the start of the first line is shifted left) – David Carlisle Apr 02 '22 at 18:15
  • I have updated \list{} with \begin{list}, and \endlist with \end{list}, it also works, it is easy to understand, however, could you tell me what the comand \item\relax mean? does it mean that \begin{list} and \end{list} has only just one item in the content of its list environment ? Am I right? – Peter Yang Apr 02 '22 at 18:18