I am trying to create a package called lessonPlanner in which I declare some new environments via \newenvironment

So I have something like

... mwe.tex


.... In my file "lessonPlanner.sty" I have

\newenvironment{unitPlan}[1]{}Hello World{}


But LaTeX complains that I am missing a \begin{document} when it tries to parse the \newenvironment{unitPlan} definition.

So it seems I have something wrong, I would have though that all \newenvironment commands would be defined in the new packages.

P.S. I am trying to build my own package for lesson planning, where the lessons formats are defined the \usepackage{lessonPlanner} and only the content is referred to in the LaTeX document.

  • It is \usepackage. Not P by p. – user11232 Sep 14 '14 at 3:39
  • 1
    You are not giving much concrete information to work on. The first guess can't be much more help than: your defintion of the unitPLan environment contains an error of some kind --- presumably one that makes LaTeX try to typeset something while still reading the .sty file.... You should try to provide us with a minimal example (or see here). – jon Sep 14 '14 at 3:52
  • I think you are quite right, I created a \newenvironment command with some text in its definition. for instance \newenvironment{unitPlan}[1]{}Some text{}, thinking that the text would not be typeset untill \begin{unitPlan} was called but I dont think this is the case now. Thanks for your help. – Michael T Mckeon Sep 14 '14 at 4:00
  • \newenvironment{unitPlan}[1]{Hello World}{} Your Hello World is floating free in the file so LaTeX tries to typeset it before \begin{document}. By the way, unless you are trying to create flat lessons, you probably mean LessonPlanner. – cfr Sep 14 '14 at 4:11
  • 1
    See my answer for the syntax you want. – cfr Sep 14 '14 at 4:13

Your use of \newenvironment is incorrect. It should be

\newenvironment{<env>}[<args>][<opt arg>]
  {<begin env>}
  {<end env>}

If you place any content between {<begin env>} and {<end env>}, TeX will take the first token as the end (H in this case), leaving the rest as text that should possibly be set. And, of course, in the preamble, you cannot have this, since text is only set after \begin{document}. That gives rise to your error of "Missing \begin{document}".

Most likely your definition should resemble

  {Hello World}% \begin{unitPlan}
  {}% \end{unitPlan}

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.