I'm looking into generating .m files programmatically and would like to explore different possibilities of formatting their content when opened in the front end.

For example, if you write

(* ::Subsection:: *)
(* See also *)
(* ::Text:: *)
(*foo, bar.*)

inside a .m file, the front end will display this as

enter image description here

This way, one can actually make .m files look nice while preserving their key advantages against notebooks (plain text, perfect for version control system, editing a single block doesn't modify the whole file etc.)

Apparently, there are special keywords inside comments such as (* ::Section:: *), (* ::Subsection:: *), (* ::Text:: *), (* ::Title:: *) etc. that are parsed by the front end in a special way.

Does someone know, where can I find the full list of such keywords and their usage examples?

EDIT: While my original question regarding styles has been answered by Brett Champion, I'm also interested in general tips and tricks or guides regarding the output/style formatting of .m files. So please don't hesitate to post an answer if you can share some interesting piece of information on that.


1 Answer 1


The XXXX in (* ::XXXX:: *) can be any named style such as you might find in the Format > Style menu.

If you look at the underlying cell expression in the frontend, you'll see:

Cell[..., "XXXX"]

Note that the XXXX is automatically turned into a string when the frontend is reading the file, so you can't use this to apply arbitrary styling options to the content.

  • $\begingroup$ Many thanks. This indeed answers my original question, so I'm accepting your answer. I've also slightly extended the scope of my question, since I'm interested in understanding the whole scope of styling and formatting with respect to .m files. If you can point me to any summary/guide, that would be certainly very helpful. $\endgroup$
    – vsht
    Apr 5, 2021 at 11:12
  • $\begingroup$ @vsht it might be helpful to ask a new question specifically targeting this more focused problem, and preserve the old question. You might find it better to then link to this question, as it was, to better clarify your new & separate question. $\endgroup$ Apr 6, 2021 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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