New answers tagged

1

Using undocumented FrontEnd`ExportPacket command you can get exactly the same formatting as with Copy As ► Plain Text (i.e. without the line breaks and extra spaces): s = First[FrontEndExecute[FrontEnd`ExportPacket[Cell[BoxData[ToBoxes[a]]], "PlainText"]]] {-11 \[Psi]^2 \[Lambda][1]+6 \[Psi] \[Lambda][2],35 \[Psi]^2 \[Lambda][2],11 \[Psi]^2 \[Lambda][1]...


2

Have a look at TeXTableForm.m: Converting Mathematica Lists to LaTeX Tables it is working quite well: t = Table[i, {i, 1, 22}] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \ 20, 21, 22} TeXTableForm[t, 5, "tab1.tab"] "tab1.tab" Import[".../tab1.tab"]


2

One way to write it is to let $$f(x) = \frac{z \log (1-x)+(1-2 z) \log (x)+(z-1) \log (x z-x+z)}{z (2 z-1)}$$ and write $f^{(-1)}\left(\frac{z \log (1-{a_0})-2 z \log ({a_0})+z \log ({a_0} z-{a_0}+z)-\log ({a_0} z-{a_0}+z)+\log ({a_0})}{z (2 z-1)}-\frac{t}{2}\right)$ for InverseFunction[..][..]. So in regular mathematical notation, the ...


1

I may have found a nice way. However, I think the output is a bit ugly. Here's the working code : NullCurve1[n_] := NDSolve[{ u'[r] == 2/(1 - 1/r), u[0] == 2 n }, {u}, {r, 0, 1}, Method -> Automatic, MaxSteps -> 100000 ] NullCurve2[n_] := NDSolve[{ u'[r] == 2/(1 - 1/r), u[5] == 2 n }, {u}, {r, 1, 10}, Method -&...


2

I will use Eq. 22.7 of your reference $ v = 2 r + 4 m \ln(|r - 2 m|) + B$ The obliques are, I guess is given by $v=-u$. For scaling I am considering $u=2mr$. m = 1/2; Show[ContourPlot[Evaluate@Table[ v == 2 r + 4 m Log[Abs[r - 2 m]] + n, {n, -5, 5}], {r,0,4 m}, {v,-3m,3m}, ContourStyle -> Blue, AspectRatio -> 3/2], ContourPlot[Evaluate@Table[v == -...


2

This changes E**argument to exp(argument): Unprotect[Power]; Power /: Format[Power[E, x_], FortranForm] := exp[x] Protect[Power]; {FortranForm[E^(3*z)], FortranForm[Exp[2*z^3]]} (* Out: {exp(3*z), exp(2*z**3)} *)


3

Original answer The reason for getting extra quotes is that these extra quotes are explicitly present in the box form of the expression generated by such functions as EngineeringForm, NumberForm etc.: ToBoxes@EngineeringForm[6.08717*10^6] TagBox[InterpretationBox[ RowBox[{"\"6.08717\"", "\[Times]", SuperscriptBox["10", "\"6\""]}], 6.08717*10^6, ...


5

You can use Trace with TraceDepth option set to 1 to get evaluation steps giving whole expression, and format result as you want it. Function performing this actions can be assigned to $Pre to be automatically used for all inputs. ClearAll[showSetSteps] SetAttributes[showSetSteps, HoldAllComplete] showSetSteps[Set[lhs_, rhs_]] := With[{trace = Replace[...


13

Citing this 1996 year MathGroup post by Dave Wagner, A similar function, Continuation[n], is called to format the character at the beginning of continued lines. So, for example, the definition Format[Continuation[n_]] := StringForm["(``)",n] would place a line number inside of parentheses on the second and subsequent lines of a multi-line ...


2

Here is a simple and universal function which formats timings (for real-time monitoring of elapsed time one should replace Round with Floor): formatTiming = StringJoin[{If[# >= 100, ToString@#, IntegerString[#, 10, 2]] &@Floor[#/3600], ":", IntegerString[Floor[Mod[#, 3600]/60], 10, 2], ":", IntegerString[Mod[#, 60], 10, 2]} &@...


7

After a quick Google search I came across this, which provides a description. Translation: Continuation[n] is the result at the beginning of the nth line in a multiline printed Expression. The default value of Continuation is either the string " " or the string ">". The value of Continuation is can be changed with the command Format[Continuation[n_]]:=...


7

\[Continuation] is also the name of the special character used to indicate that input should be interpreted as continuing in the next line, or to break output too long for the current window. I suspect Continuation[] to be the operator form of that infix symbol. On second thought, I suspect that the formatting references you found are linked to special ...


2

You can use an intermediate expression that can be returned by your function, not printed as side effect. Then you can use $Post to post-process this returned expression, so that it'll result in multiple printed cells. ClearAll[multipleCellsOutput, printMultipleCellsOutput] printMultipleCellsOutput = # /. multipleCellsOutput[cells_List] :> Scan[...


5

New Implemantation: f[x_] := Dynamic[ NotebookWrite[EvaluationCell[], Cell[BoxData[ToBoxes[#]], "Echo"] & /@ Range[x]];, None, TrackedSymbols :> {}, Evaluator -> None] Original Answer: As Dynamic objects are only evaluated when they are visible, one can use them to print cells only when there is no ; at the end of the input. The following ...


3

This one checks if the input ended with ; and prints Echo cells if it didn't. f[x_] := If[ Cases[NotebookRead[EvaluationCell[]], BoxData[RowBox[{___, last_}]] :> last] == {";"}, Null, CellPrint[ExpressionCell[#, "Echo"]] & /@ Range[x]; ] For example: f[5] f[5]; This approach can be extended to also cover CompoundExpressions ...



Top 50 recent answers are included