电子邮件中的 mathematica 代码并保持格式与笔记本相同 [英] mathematica code in email and keeping formatting the same as notebook

查看:25
本文介绍了电子邮件中的 mathematica 代码并保持格式与笔记本相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,当发送带有 Mathematica 代码的电子邮件时,实践是这样做

As we all know, when one is to send email with some Mathematica code in it, the practice is to do the following

选择单元格,Cell->ConvertTo -> INPUT FORM,然后COPY AS TEXT

Select the cell, Cell->ConvertTo -> INPUT FORM, then COPY AS TEXT

然后将代码粘贴到电子邮件或任何其他交换媒体中.

Then paste the code into the email, or any other exchange media it is.

上述唯一的问题是,当另一端从电子邮件中复制文本并将其粘贴回 Mathematica 笔记本时,代码将不再以原始形式显示(之前转换为 INPUT FORM).

The only problem with the above, is that when, on the other end, one copies the text from email and paste it back into a Mathematica notebook, the code will then no longer appear as it was in the original form (before the converting to INPUT FORM).

因为当插入从电子邮件复制的文本到 Mathematica 笔记本时,它就变成了一个标准的表单单元格.一切都好,除了原来的代码格式都丢失了.

Because when one inserts the text copied from the email to Mathematica notebook, it becomes a standard form cell. All well, except the original code formatting is all lost.

没有的话试试吧,把一个单元格转换成INPUT FORM,代码会改变形状,在这个操作之前我找不到找回原始形式的方法.

Try it if you have not, convert a cell to INPUT FORM and the code will change shape, and I could not find a way to get back the original form before this operation.

有没有办法通过电子邮件发送 Mathematica 代码,当然是文本形式,以便它保持相同的形状,并且在转换之前以标准形式显示时的外观相同?

Is there a way to email Mathematica code, in text of course, so that it keeps the same shape, and appear the same as it was originally when it was in standard form before the conversion?

谢谢--纳赛尔

推荐答案

使用 Code 样式 (ALT/CMD-8) 格式化的单元格在使用复制粘贴时保留所有格式.我一直使用它们来格式化 SO 的帖子.好吧,说实话,我几乎一直使用 Code 单元格,除了一次性输入或一次性输入.

Cells formatted with the Code style (ALT/CMD-8) retain all formatting when using copy-and-paste. I use them all the time to format postings for SO. Well, truth be told, I use Code cells pretty much all the time, except for one-shot or throw-away input.

使用代码样式还有其他优点.它可以轻松评估笔记本中的所有定义,而无需评估所有附带和测试表达式:ALT/CMD-单击任何 Code 单元格的单元格括号,然后按Shift-Enter.此外,代码 单元格会自动成为初始化单元格,这通常正是您想要在笔记本中定义的内容.最后,当 Mathematica 在笔记本中发现 Code 单元格时,它会提供创建一个仅包含这些单元格的自动保存包.

There are other advantages to using the Code style. It makes it easy to evaluate all of the definitions in a notebook, without also evaluating all of the incidental and test expressions: ALT/CMD-click on the cell bracket of any of the Code cells and then press SHIFT-ENTER. Also, Code cells automatically become initialization cells, which is frequently exactly what you want for the definitions in a notebook. Finally, when Mathematica spots Code cells in a notebook it offers to create an auto-save package that contains only those cells.

Code 单元格的缺点是您失去了 Mathematica 对具有 Input 样式的单元格执行的自动格式设置 -- 但话说回来,自动格式设置正是我们在这个问题的上下文中试图避免.

The downside to Code cells is that you lose the automatic formatting that Mathematica performs on cells with the Input style -- but then again that automatic formatting is precisely what we are trying to avoid in the context of this question.

这篇关于电子邮件中的 mathematica 代码并保持格式与笔记本相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆