Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: StylePrint problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20489] Re: StylePrint problem
  • From: paulh at wolfram.com (P.J. Hinton)
  • Date: Wed, 27 Oct 1999 02:04:53 -0400
  • Organization: "Wolfram Research, Inc."
  • References: <7v3apq$5l1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <7v3apq$5l1 at smc.vnet.net>, "Dana DeLouis" <dana2 at email.msn.com> writes:

>Hello.  I am trying to learn Programming in Mathematica 4.  I am also studying math
>problems.
>If I know that I am going to do  30+ problems at the end of a chapter, I
>want to avoid typing in the text..Problem #1, Problem #2, etc
>
>I found this example in the "Tour of Mathematica" section of "The
>Mathematica Book."
>
>Do[StylePrint["Problem # " <> ToString[i], "Section"], {i, 10}]
>
>Which works...kind of.  After the above prints out correctly, I move the
>cursor between say Problem #4, and Problem #5 to begin solving Problem #4.
>As soon as I hit enter, all the output from Problem #5, down to  the last
>one is deleted!
>
>Does anyone do anything similar?  Is there another command that I should be
>using instead.  I  have looked for a long time.  Thank you for any insight /
>solution.  Dana

This sort of task is ideal for palette buttons and counters.

Paste these expressions into individual cells and evaluate them in order
of appearance.  They will generate 2 x 1 palette of buttons.  Clicking
on the first button sets down a Section cell identifying the section
of the book from which the problems came.  The second button pastes
cells that automatically number the problem.  To create a standalone
palette notebook, select the array of buttons and then perform the
menu command File -> Generate Palette from Selection.

(but1 =
      ButtonBox[
        "Paste Section Heading",
        ButtonEvaluator -> None,
        ButtonFunction :> 
          NotebookWrite[
            FrontEnd`InputNotebook[], 
            Cell[
              TextData[
                {"Section ",
                  CounterBox["Section"]
                  }
                ],
              "Section"
              ]
            ],
        Active -> True
        ]) // DisplayForm


(but2 = 
      ButtonBox[
        "Paste Problem Heading",
        ButtonEvaluator -> None,
        ButtonFunction :> 
          NotebookWrite[
            FrontEnd`InputNotebook[], 
            Cell[
              TextData[
                {"Problem ",
                  CounterBox["Subsection"],
                  " Section ",
                  CounterBox["Section"]
                  }
                ],
              "Subsection"
              ]
            ],
        Active -> True
        ]) // DisplayForm


GridBox[
    {{but1}, {but2}},
    RowSpacings -> 0
    ] // DisplayForm

To initialize the value of the Section counter to something other
than 1.  Click on the bracket of the first Section style cell in
the notebook and open the Option Inspector with the menu command
Format -> Option Inspector...

Within the Option Inpsector dialog, set the window to your working
notebook and the scope indicator to "selection."  Enter the text 
"CounterAssignments" in the text field adjacent to the Lookup button 
and then click on it.  The value of CounterAssignments may look 
something like this.

CounterAssignments->{{"Subsection", 0}, {"Subsubsection", 0}}

Change it to read:

CounterAssignments->{{"Section", <desired value - 1>,
  {"Subsection", 0}, {"Subsubsection", 0}}

So if you wanted to start the Section numbering at 43, you would enter
the value of 42 (isn't that the answer to all questions?)

For more information, check out the CounterBox tutorial at MathSource.


--
P.J. Hinton
Mathematica Programming Group           paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.


  • Prev by Date: Re: Partitioning lists
  • Next by Date: Re: StylePrint problem
  • Previous by thread: Re: StylePrint problem
  • Next by thread: Mathematica crash on HP