[Date Index]
[Thread Index]
[Author Index]
Re: Re: Bilateral cell problem w/ Manipulate
*To*: mathgroup at smc.vnet.net
*Subject*: [mg88369] Re: [mg88349] Re: Bilateral cell problem w/ Manipulate
*From*: "J. McKenzie Alexander" <jalex at lse.ac.uk>
*Date*: Sat, 3 May 2008 06:16:08 -0400 (EDT)
*References*: <fvc60m$9me$1@smc.vnet.net> <200805020745.DAA05506@smc.vnet.net>
Apologies for the length of this post!
Grid, Row, Column, and the like work great for manual layout in a
notebook, but they don't work well for programmatic interactions with
a notebook, as far as I can tell. One of the advantages of the Make
Bilateral Cells palette is that one can transform an entire subset of
cells in a notebook into bilateral cells by clicking a button (and
then undo it, by clicking another button). If one had to manually
layout the bilateral cells (and then suppress the code used to
generate them) it would be too tedious to bother with.
Here's an example of what I mean when I say that Row, Column, and Grid
"don't work well" for this kind of manipulation.
The natural construct to try for laying out a bilateral cell is the
following:
Row[{
Cell["This is a caption.", "MathCaption"],
Column[{
Cell[BoxData[RowBox[{"1", "+", "1"}]], "Input"],
Cell[BoxData["2"], "Output"]
}]
}]
Evaluating that just gives the textual representations of the cells,
prefixed by "Out[n]=".
If you put the Row[{...}] expression inside CellPrint[ ], you still
get the textual representation of the cells, rather than the displayed
form of the cell... but at least we no longer get the "Out[n]=" label.
Ok. Suppose we put a DisplayForm@ in front of the three Cell heads, so
that it looks like this:
CellPrint[
Row[{
DisplayForm@Cell["This is a caption.", "MathCaption"],
Column[{
DisplayForm@ Cell[BoxData[RowBox[{"1", "+", "1"}]], "Input"],
DisplayForm@ Cell[BoxData["2"], "Output"]
}]
}]
]
That sort of works, but it requires us to evaluate the expression
manually inside an input cell. It also doesn't preserve the formatting
? the MathCaption cell appears with a Courier font, rather than Times,
on my machine.
Moreover, in order to make bilateral cells programmatically, we would
need to be able to use it with NotebookWrite. But the following gives
an error:
NotebookWrite[InputNotebook[],
Row[{
DisplayForm@Cell["This is a caption.", "MathCaption"],
Column[{
DisplayForm@Cell[BoxData[RowBox[{"1", "+", "1"}]], "Input"],
DisplayForm@Cell[BoxData["2"], "Output"]
}]
}], After
]
If you put a CellPrint@ before the Row, it does write the cell into
the notebook, but it also writes a Null after it, and still doesn't
preserve the formatting of the MathCaption.
The fundamental problem is that NotebookWrite breaks dynamic objects,
and so can't be used with arbitrary cells. The following inserts a
broken cell into the notebook:
NotebookWrite[InputNotebook[],
Manipulate[Plot[Sin[a x], {x, 0, 10}], {a, 1, 10}],
After
]
Moreover, you still get an error if you try the following:
1. Evaluate the above Manipulate[...].
2. Get the raw cell expression using "Show Expression", and copy it to
the clipboard.
3. In another input cell, define the variable c1 to equal that raw
cell expression (it's long).
4. Evaluate NotebookWrite[InputNotebook[], c1, After]
However, in this case CellPrint[ c1 ] does give you a functioning
Manipulate cell! So, CellPrint works with Dynamic objects but
NotebookWrite doesn't.
Cheers,
Jason
On 2 May 2008, at 08:45, Helen Read wrote:
> J. McKenzie Alexander wrote:
>> Although AuthorTools is considered "legacy code" for Mathematica 6,
>> I've still been using the bilateral cells palette because I don't
>> know =
>
>> of any other better alternative. Although it still works well, I've
>> found that it sometimes breaks =97 but sometimes not =97 when using
>> Manipulate, and I don't know why.
>
> You might consider trying the new Grid, Row, Column, and GraphicsGrid,
> GraphicsRow, GraphicsColumn instead of the bilateral cells.
>
> --
> Helen Read
> University of Vermont
>
--
Dr J. McKenzie Alexander
Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science
Houghton Street, London WC2A 2AE
Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm
Prev by Date:
**Re: Locator**
Next by Date:
**Re: Problem/bug with ends of thick lines in graphics**
Previous by thread:
**Re: Bilateral cell problem w/ Manipulate**
Next by thread:
**Re: Re: Re: Does Mathematica really need more printed,**
| |