Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Can someone explain the following preamble to me? This is copied and pasted from a problem set template my T.A. made to help us typeset our homework... I'd really like to understand how it works. The thing that is stumping me the most is lines 5-6; why was it necessary to define a new TeX macro. Is it usually necessary to do so in LaTeX documents?

\setlength{\parskip}{5pt plus 1pt} 


  \vspace{.25in} \hrule \vspace{0.5em}%
  \noindent{\bf #2}%
  \vspace{0.8em} \hrule \vspace{.10in}%
    {\bf (#1)} %
share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

@egreg's answer provides the means to correct the code, as well as introducing some improvements. Consider this answer merely an explanation as to way the original (faulty) code still compiled. The sequence of events that TeX followed are

  1. \def\indented#1{\list{}{}\item[]}

    This defined the macro (not environment) \indented to take one argument. Since it is not used in the expansion, it will be discarded. For example, using only the above (and removing line 6 (given below in [2]), would gobble something when using \indented{something}.

  2. \let\indented=\endlist

    This rewrites the definition of \indented as defined in [1] above, making [1] useless.

  3. \begin{indented} ... \end{indented}

    Since the macro \indented is not undefined (or, defined) at this point - however meaningless its definition is, \begin{indented} is expanded to \indented, which is \endlist, which has no problem completing. I'm stumped by why TeX does not produce an error when trying to expand \endindented which is undefined. However, this could be a case where defining a start \<myenv> as the end \end<myenv> (like in [2]) may settle out the unmatched start-and-end of an environment <myenv>.

  4. Finally, since the indented environment was never actually formally defined as anything, it didn't amount to anything in terms of the visible output.

share|improve this answer
add comment

Line 6 should read


These two lines are just a slightly more efficient way to say


When you do \newenvironment{xyz} you are really defining two commands: \xyz and \endxyz, which are executed (along with other commands) when LaTeX finds \begin{xyz} and \end{xyz}. Your TA is just showing off. :)

It's quite mysterious why the definition of question doesn't say


instead of \addtocounter{questionCounter}{1}, thus inhibiting the possibility to say \label{a-question} in order to refer later to a question. It's quite mysterious also why not defining

   \begin{list}{}{}\item[]\textbf{(#1)} }

that would not need an auxiliary environment indented.

Also redefining \part doesn't seem a good idea.

share|improve this answer
In short, the OP's TA wanted to show off, but failed to do so. ;-) –  lockstep Sep 10 '11 at 16:07
I suspect his name is Ben Lee User. ;-) –  egreg Sep 10 '11 at 16:30
so is it not usually necessary to define TeX macros like that within a LaTeX document? even if it is more efficient, the main reason LaTeX exists is to provide an an abstracted TeX that makes page layout easier, right? –  Alex Lockwood Sep 12 '11 at 5:02
add comment

As a complement to egreg's answer: The code lines


(as amended by egreg) define the indented environment as a one-item list (and issue the necessary \item command). This way, the spacing parameters of the new environment will conform to that of lists like itemize and enumerate. (The LaTeX standard classes use the same trick to define e.g. the quote environment.)

share|improve this answer
add comment

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.