1
$\begingroup$

I have met problem in the use of style sheet. In using the External Evaluation of Python in Mathematica, If we choose the style sheet as "Default", pressing the "Enter" will cause a line break in the cell. However, When I changed the style sheet into "Journal Article", Pressing the "Enter" will run the python program. To let it more clear, I list the screenshot [![enter image description here][1]][1]

I also noticed that the Equation numbered in Journal articel will create new cell rather than a line break too. Any one knows how to change the behavior of pressing Enter?

The “Enter” is the "Left Enter", not the "Right Enter" in number area. My mathematica is 12.0 and in Windows 10. [1]: https://i.stack.imgur.com/1Dxy0.png

$\endgroup$
2
  • $\begingroup$ Regarding the python external evaluation cell concerns: What kind of system are you using, and which enter are you pressing? Left/right? Note that these keys represent different operations in different systems. $\endgroup$ – CA Trevillian Aug 22 '20 at 8:04
  • 1
    $\begingroup$ Sorry for the uncomplete information, I have added the missed information in my question $\endgroup$ – Knife Lee Aug 22 '20 at 8:34
2
$\begingroup$

Pressing the “enter” key in the Python External Evaluation cell becomes “run” instead of “line break”

I think the python code cell is not evaluated. The "Enter" key merely creates a new cell rather than inserts a new line. (If you have confirmed that the statement above isn't true, please edit the question.)

This is due to an option ReturnCreatesNewCell -> True specified for StyleData["Notebook"] in the stylesheet JournalArtical.nb.

You can evaluate one of these to disable such an option:

SetOptions[EvaluationNotebook[], FrontEnd`ReturnCreatesNewCell -> False]

SetOptions[EvaluationNotebook[],
    StyleDefinitions -> Notebook@{
        Cell@StyleData[StyleDefinitions -> FrontEnd`FileName[{"Article"}, "JournalArticle.nb", CharacterEncoding -> "UTF-8"]],
        Cell[StyleData@"ExternalLanguage", FrontEnd`ReturnCreatesNewCell -> False]
    }
]

SetOptions[EvaluationNotebook[],
    StyleDefinitions -> Notebook@{
        Cell@StyleData[StyleDefinitions -> FrontEnd`FileName[{"Article"}, "JournalArticle.nb", CharacterEncoding -> "UTF-8"]],
        Cell[StyleData@"Notebook", FrontEnd`ReturnCreatesNewCell -> False]
    }
]
```
$\endgroup$
1
  • $\begingroup$ Thank you so much, I test your first command and it solves my probelm! $\endgroup$ – Knife Lee Aug 22 '20 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.