Message Boards Message Boards


FrontEnd: Creating an Input Style that produces a specific Output Style.

Posted 10 years ago
1 Reply
1 Total Likes

Suppose that I have created two input styles (say the normal input style from Core.nb) and another called myInputStyle; also, suppose that I have another Output Style called myOutputStyle.

I have a suite of notebooks with embedded style sheets that have these two different kinds of input and output styles.

I'd like to have myInputStyle produce only myOutputStyle.

I do realize that this will not play nice with standard style sheets.  But, I'll solve that problem later----I hope.

I am not sure where to look in the documentation for this----or find an example from which I can extrapolate a solution.

If anyone has a pointer to the right direction, or even the name of a Cell Option to look at, I'd be grateful.
Thanks, Craig
POSTED BY: W. Craig Carter
CellEvaluationFunction might be what you are looking for.

The following creates a notebook where evaluating the first cell gives a result 
similar to a typical evaluation.  Evaluating the second cell gives a result with 
"Input" style instead.  Evaluation the third cell gives a result with "Text" style.

    Cell[BoxData[RowBox[{"2", " ", "3"}]], "Input",
     CellEvaluationFunction -> (NotebookWrite[EvaluationNotebook[],
         Cell[BoxData[ToString[ToExpression[#]]], "Output"]] &)],
    Cell[BoxData[RowBox[{"2", " ", "3"}]], "Input",
     CellEvaluationFunction -> (NotebookWrite[EvaluationNotebook[],
         Cell[BoxData[ToString[ToExpression[#]]], "Input"]] &)],
    Cell[BoxData[RowBox[{"2", " ", "3"}]], "Input",
     CellEvaluationFunction -> (NotebookWrite[EvaluationNotebook[],
        Cell[ToString[ToExpression[#]], "Text"]] &)]

You should be able to add CellEvaluationFunction to your 'myInputStyle' style and specify the 'myOutputStyle' style in the corresponding NotebookWrite[].
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract