0

How do I post Mathematica code in StackExchange properly? I read some instructions that told me I should copy the Mathematica code from the Mathematica notebook with Copy as > Plain text or Copy as > Input text, paste into the SE code editor pane, and put it between \$ \$,

When I did this I still did not get well-formated equations. For example, I got:

$ eq1[zz_, \[Beta]_] := 2*Subscript[\[Lambda], 1]*v1[\[Beta]]^2 $

So what did I miss?

Actually I still haven't found an answer. I followed the instruction in How to copy code from Mathematica so it looks good on this site

I did the following for a Mathematica cell that I wanted to post Mathematica.SE site. I convert the contents of the cell to Raw InputForm and then pasted intp SE editor between \$ $, like

$ eq1[zz_, \[Beta]_] := 2*Subscript[\[Lambda], 1]*v1[\[Beta]]^2 + 2*Subscript[\[Lambda], 2]*v2[\[Beta]]^2 $

Nothing, so I also tried to put between { }, like

{eq1[zz_, \[Beta]_] := 2*Subscript[\[Lambda], 1]*v1[\[Beta]]^2 + 2*Subscript[\[Lambda], 2]*v2[\[Beta]]^2 }

So I'm afraid I didn't understand the instructions in the referred post.

7
  • Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Commented Jan 6, 2016 at 10:17
  • Let me try here, I convert the equation to : Raw InputForm, then past here between \$ $: $eq1[zz_, [Beta]_] := 2*Subscript[[Lambda], 1]*v1[[Beta]]^2 + 4*Subscript[[Lambda], 2]*v2[[Beta]]^2} $ or \{} {eq1[zz_, [Beta]_] := 2*Subscript[[Lambda], 1]*v1[[Beta]]^2 + 4*Subscript[[Lambda], 2]*v2[[Beta]]^2} Commented Jan 6, 2016 at 10:46
  • Please look at my question, because I added. Commented Jan 6, 2016 at 15:21
  • 2
    @S.S. I don't know where you saw you should the enclose code you copy from a notebook in \$ \$, but that is wrong and don't do it. Commented Jan 7, 2016 at 0:11
  • Unless the code has special symbols or formatting, you can just copy it from your notebook and paste it into SE. If it is just a short piece of code, you can include it in a line of text by surrounding it by backquotes, as in x + y. However, it is a longer piece of code or you wish it to stand alone on a line, paste it into a blank line, highlight it, and click the {} symbol about the SE code editor box. (Equivalently, separate it from text by a blank line and indent it four spaces.) In this case, do not surround it by backquotes. Do not surround it by dollar signs unless you want LaTex. Commented Jan 7, 2016 at 3:45
  • On the other hand, if you have code with complex formatting, convert it to input form by using the Mathematica InputForm command, and then copy and paste the result. This leaves Greek letters to format properly. For many web viewers, use Halirutan's editor. See also my earlier question. Commented Jan 7, 2016 at 3:54
  • Thanx for the replies. Commented Apr 22, 2016 at 18:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.