NotebookPut[
Notebook[{Cell["October 7, 2008", "Text", TextAlignment -> 1,
FontSize -> 24, Bold,
CellMargins -> {{Inherited, Inherited}, {50, Inherited}}],
Cell["Probability Of Acceptance", "Section", "Text",
CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {4, 3}}],
Cell["Use the formula,", "Text", TextJustification -> 1,
Hyphenation -> True, FontSize -> 16, Bold, CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {10, Inherited}}],
Cell[BoxData[
RowBox[{ RowBox[{"(", GridBox[{{"c"}, {"i"}}], ")"}],
SuperscriptBox["p", "i"],
SuperscriptBox["(1-p)", "c-i"]}] ] , "Text",
FontSize -> 16, Bold, TextJustification -> 1, Hyphenation -> True,
CellMargins -> {{Inherited + 35, Inherited}, {10, Inherited}}],
Cell["to compute the probability that acceptance sampling deems a \
lot to be acceptable. Values of n, c amd p are specified by the \
user.", "Text", FontSize -> 16, Bold, TextJustification -> 1,
Hyphenation -> True, CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {10, Inherited}}]}]]
The cell that prints the formula was suggested to me by Bob. It
prints the formula correctly.
My attempts to insert a summation sign in front of the formula failed.
The command
Sum[f,{i,0,c}]
didn't do the job. Maybe I didn't put it in the right place.
Latex formulas are elegant (suitable for framing). Can Mathematica
match the elegance of Latex? If so I want to know how to do it.
John
> The cell that prints the formula was suggested to me by Bob. It
> prints the formula correctly.
> My attempts to insert a summation sign in front of the formula failed.
> The command
>
> Sum[f,{i,0,c}]
>
> didn't do the job. Maybe I didn't put it in the right place.
you still have failed to explain what you are trying to do. I have
hardly ever seen the need to create formulas in notebooks the way you
are trying. Mathematica's Frontend is a nice WYSIWYG formula editor, why
are you bothering with the underlying boxes at all?
> Latex formulas are elegant (suitable for framing). Can Mathematica
> match the elegance of Latex? If so I want to know how to do it.
If you like Latex, why don't you try this:
TeXCell[s_String] :=
ImportString["$\sum _{i=1}^n x_i$", "TeX"][[1, 1]]
CreateDocument[{
"Here is a formula:",
TeXCell["$\sum _{i=1}^n x_i$"]
}]
still wondering what the hell you are trying to achieve...
albert
TeXCell[s_String] := ImportString[s, "TeX"][[1, 1]]
albert
Sum[Binomial[c, i] p^i (1 - p)^(c - i), {i, 0, c}] //
HoldForm // TraditionalForm
??
Are you simply using Mathematica as a scientific word processor? A kind of
MaTeX? Interesting, but it seems you will lose all the active calculational
and dynamic capabilities of Mathematica. That's what you're paying for. I
think it is possible to write active notebooks that look like classical
papers - but WRI doesn't always make it easy.
--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
"John" <jw...@lehigh.edu> wrote in message news:gckn71$noe$1...@smc.vnet.net...
John,
One way is to do:
NotebookPut[
Notebook[{Cell["October 7, 2008", "Text", TextAlignment -> 1,
FontSize -> 24, Bold,
CellMargins -> {{Inherited, Inherited}, {50, Inherited}}],
Cell["Probability Of Acceptance", "Section", "Text",
CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {4, 3}}],
Cell["Use the formula,", "Text", TextJustification -> 1,
Hyphenation -> True, FontSize -> 16, Bold, CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {10, Inherited}}],
Cell[BoxData[
RowBox[{RowBox[{UnderoverscriptBox["\[Sum]",
RowBox[{"i", "=", "0"}], "c"], "(", GridBox[{{"c"}, {"i"}}],
")"}], SuperscriptBox["p", "i"],
SuperscriptBox["(1-p)", "c-i"]}]], "Text", FontSize -> 16,
Bold, TextJustification -> 1, Hyphenation -> True,
CellMargins -> {{Inherited + 35, Inherited}, {10, Inherited}}],
Cell["to compute the probability that acceptance sampling deems a
lot to be acceptable. Values of n, c amd p are specified by
the
user.", "Text", FontSize -> 16, Bold, TextJustification -> 1,
Hyphenation -> True, CellFrame -> False,
CellMargins -> {{Inherited, Inherited}, {10, Inherited}}]}]]
But this is so much work, there must be a better way. And there is.
Use Mathematica as it was designed to create a technical document and
try the following: (don't forget that you need to highlight the
desired text or cell and then apply the indicated command - I have
specified the Mac menu commands and shortcuts, so if you have a
Windows or Linux or other version of Mathematica substitute the
correct menu command or shortcut, although the menu commands are
usually the same)
1. File/New Notebook (or Command-n keyboard shortcut)
2. Type in "October 7, 2008" and set it to be a "Text" style cell
(Format/Style/Text or Command-7 shortcut), with a font size of your
choice (Format/Size/Larger or shortcut Command-= on a Mac) and right
justified (Format/Text Alignment/Align Right), and make it bold
(Format/Face/Bold or Command-b shortcut)
3. Create the next cell with "Probability Of Acceptance" as a
"Section" cell (Format/Style/Section or shortcut Command-4) and change
the text size and boldness as in step 2
4. Create the next cell with "Use the formula," as a "Text" cell with
size and boldness as desired
5. Create the next cell with the formula as a "Text" cell, then use
the"BasicMathInput" palette to enter the Sum, the binomial
coeffecient, and the exponential elements of the formula, and then set
the size and boldness as desired
6. Create the next cell with the "to compute the ..." phrase as a Text
cell with size and boldness as desired
7. You can indent the formula by using the Ruler - first highlight the
formula cell (click on the cell bracket is one way), then just drag
the margin indicators right underneath the ruler (they look like bold
right angle symbols) to adjust the left margin to the desired amount.
You can turn on the "Ruler" from the "Window" menu command, and you
might also turn on the "Toolbar" as well. The Toolbar shows what style
the current cell is (Section, Text, Input, Output, etc) and shows text
justification and font shortcuts too, as well as a Print and Help
icons. I prefer to have both (Ruler and Toolbar) visible at all times,
but that is entirely up to you as to what you prefer.
You are done - and not one BoxData, or Grid or anything. So you need
to explore how to create cells of different types (Section,
subsection, text, input, etc) and how to modify their visual
attributes, rather than create them with the low-level Mathematica
commands like LaTeX does. This is so much easier IMO, but if you
really want to you can look at the underlying code by doing a "Cell/
Show Expression" menu command to see all the low-level commands that
form the document you see. By the way, if you want several cells to
have the same attributes, highlight several of them at once by
clicking on the first cell bracket while holding the "Shift" key, and
then click on the last cell bracket, then do the size, style, etc
commands to all of them at once. If some of the cells are not adjacent
to each other (for example the 1st, 3rd and 5th cells you want to all
change to bold), then use the Command key instead of the Shift key and
click on only the desired cells before doing the desired change.
I would post the resulting notebook, but don't know how to get complex
equations like this example to reproduce correctly -- can someone
suggest how to do this? I will e-mail John the resulting notebook
separately so he can see exactly what the notebook looks like when
created this way.
You can also start to explore the use of cell groups where you might
have some Input cell with a long program to create a plot, but you
dont really want to show the code in a presentation - in that case put
the code and the plot in a cell group, then double-click on one or the
other to hide the other cells in the group, e.g. double-click on the
cell bracket of the plot and the input cell with the code is hidden,
or double click on the input cell with the code and the plot is
hidden. But notice that an Input cell with a program is always a
member of the cell group that also contains it's output cell, so the
step to make them part of a group may already be done. To get back the
hidden cells, just double-click on the outermost cell bracket on the
right of the notebook window. To group several cells together, just
click on their cell brackets and then do a "Cell/Grouping/Group Cells"
menu command. You can put as few as 2 or as many as desired in a
group. You can ungroup them later as well with the "Cell/Grouping/
Ungroup cells" menu command.
You can also turn on or off the cell brackets so they are invisible or
visible as you wish. One way to do this is with the Option Inspector,
but be careful setting things with the Option Inspector as it can do
things that are not easy to undo.
Doing things this way, avoids having to deal with the low-level code
that John's example has. It is hard at first to remember where all the
commands are and what the shortcuts are, but as with anything else,
the more you use it the more you will remember.
Hope this helps explain things a bit. But explore using Mathematica on
your own and look at as many different ways of using as possible to
see how versatile and powerful it is.
Also, I think there is a mistake as the phrase "Values of n, c and p"
should be "Values of c, i, and p" (there is no "n" in this equation).
-Bob Freeman
Cheers -- Sjoerd
Bob,
There is a mistake in my formula. The upper number in the
combinatorial formula should be n and the exponent of (1-p) should be
n-i. I am still working on the alternate method that you described in
your message.
Thank you for your helpful advice.
John
1) Carefully decide what it is you want to do.
2) Look at some of the documentation and think about how what you want
to do differs from the thousands of examples that are already there.
3) If the documentation hasn't answered your question already, explain
to us what it is that you want to do, and how it differs from all the
existing examples.
4) Tell us why you think NotebookPut is relevant to your problem!
5) Understand that Mathematica tries to evaluate expressions when it
can. Thus in the sum that you entered the summand does not depend on i,
and the sum gets trivially evaluated. If you try the following
expression, you might see something more interesting (assuming you have
not somehow defined f, and don't bury the expression in a call to
NotebookPut!).
Sum[f[i], {i, 0, c}]
People are pretty patient here, but ultimately they give up trying.
David Bailey
http://www.dbaileyconsultancy.co.uk