4

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

\usepackage{lessonPlanner}
\begin{document}

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

Werner
  • 603,163
  • It is \usepackage. Not P by p. –  Sep 14 '14 at 03: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 03: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 04: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 04:11
  • 1
    See my answer for the syntax you want. – cfr Sep 14 '14 at 04:13
  • Or @Werner's answer. (But I doubt that ping will work.) – cfr Sep 14 '14 at 04:14
  • Thanks for your help, and I'm sure its important but I don't know what the difference is between using LessonPlanner and lessonPlanner as package names, or for that matter creating a flat lesson means, can you expand a little bit further for my understanding. – Michael T Mckeon Sep 14 '14 at 04:26

1 Answers1

8

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

\newenvironment{unitPlan}[1]
  {Hello World}% \begin{unitPlan}
  {}% \end{unitPlan}
Werner
  • 603,163