5

As an example, I am using code from the link below. https://reference.wolfram.com/language/ref/ContourPlot3D.html

Usually such code has no line breaks and expands to fill the available width. Please visit the link to see this effect, assuming that it is not clear from my explanation.

ContourPlot3D[
 Evaluate[ElectroStaticPotential[{1, -1}, {{-1, 0, 0}, {1, 0, 0}}, {x,
     y, z}]], {x, -6, 6}, {y, 0, 4}, {z, -4, 4}, 
 Contours -> {-0.75, -0.25, -0.1, 0, 0.1, 0.25, 0.75}, 
 ContourStyle -> Table[Hue[i/7], {i, 0, 6}], Mesh -> None]

Is there a way to format it from the notebook interface (or by using some available package) for readability/inclusion in a limited character column space/book etc?

ContourPlot3D[
 Evaluate[
  ElectroStaticPotential[{1, -1},
   {{-1, 0, 0}, {1, 0, 0}}, {x, y, z}]
  ],
 {x, -6, 6}, {y, 0, 4}, {z, -4, 4},
 Contours -> {-0.75, -0.25, -0.1, 0, 0.1, 0.25, 0.75},
 ContourStyle -> Table[Hue[i/7], {i, 0, 6}],
 Mesh -> None
 ]

I guess it is part of the larger question: "Are there any published guidelines for formatting Mma/Wolfram language code?"

Your help is appreciated.

Syed
  • 52,495
  • 4
  • 30
  • 85
  • 2
    If you use intelliJ IDEA and then install the Mathematica plugin by Halirutan then it has an option to reformat Mathematica code – Nasser Aug 12 '21 at 15:16
  • 2
    https://github.com/WolframResearch/codeformatter – I.M. Aug 12 '21 at 15:32
  • a previous related post: https://mathematica.stackexchange.com/questions/127305/code-formatting – Syed Aug 12 '21 at 20:10
  • I am still waiting for a member to say if there are published guidelines for Wolfram language or Mathematica's code formatting. The company must have thought about it. It can be more instructive to find out why they do/don't want to publish such guidelines or provide a skeletal tool for that purpose. For interested readers, codeformatter works with strings and is recent. It will evolve hopefully. The other tool is a pretty print mechanism. In cell formatting is what I was looking for. After that save-as pdf should be good for inclusion in docs as required. – Syed Aug 15 '21 at 20:58

1 Answers1

3

I was reading this document about the launch of 12.2.

Towards the end:

In the desktop package (i.e. .wl file) editor, there’s a new (somewhat experimental) Format Cell button, that reformats code—with a control on how “airy” it should be (i.e. how dense it should be in newlines).

From a Mma12.2 notebook:

notebook incell formattter

I have to read more.

Syed
  • 52,495
  • 4
  • 30
  • 85