Questions tagged [syntax-highlighting]

Questions about highlighting for Mathematica input in the Mathematica front-end, and Wolfram Workbench.

Filter by
Sorted by
Tagged with
77 votes
3 answers
4k views

Syntax highlighting for your own functions

Mathematica has a useful feature that for functions and special constructs getting passed local variables (for example Minimize or ...
celtschk's user avatar
  • 19.1k
52 votes
4 answers
5k views

Saving a notebook as PDF, preserving syntax highlighting

Currently, one may save notebooks as PDFs from the menu by Save As... and then selecting PDF (on a Mac, I imagine it is similar on other OSs). However, the ...
acl's user avatar
  • 19.8k
44 votes
2 answers
6k views

Is it possible to change the colors of the highlighted code in the Mathematica frontend?

With Format -> Edit Stylesheet... it is possible to adjust text-properties, text-colors, formatting of equations, etc of a notebook and to use this style-definitions again by installing it as ...
halirutan's user avatar
  • 113k
44 votes
3 answers
6k views

Highlighting Mathematica code in $\LaTeX$ document

I was thinking about the best way to include Mathematica code in a $\LaTeX$ document with a nice syntax highlighting. I have tried the packages listings and minted (with pygments), which both claim ...
Eckhard's user avatar
  • 1,395
35 votes
1 answer
2k views

Customizing syntax highlighting for private cell styles

Is there any way to set up a cell style with a particular syntax highlighting? For example, I'd like to have a CProgram cell to write in blue the C special words. I have done it by setting ...
Rojo's user avatar
  • 42.6k
32 votes
1 answer
559 views

What is ColorEqualSigns and how does one use it?

Bug introduced in 9.0.1 or earlier and persists in 13.3 I'm setting up the SyntaxInformation for a package I'm writing and I'm struggling to understand what the <...
Emilio Pisanty's user avatar
28 votes
1 answer
7k views

Why are some function names red?

I need to evaluate Needs["GraphUtilities`"] before I can use functions such as GraphPath[]. When I do so, some functions get ...
CHM's user avatar
  • 3,395
26 votes
2 answers
1k views

Colored marks appearing in notebook input text?

Bug introduced in 10, persisting through 11.0.1 or later What is the causing these colored marks to appear in my Mathematica notebook? I'm particularly annoyed with the black ovals that occasionally ...
dionys's user avatar
  • 4,321
26 votes
1 answer
341 views

SyntaxInformation cannot reproduce syntax coloring of Block

Is there any way to have the same syntax coloring with SyntaxInformation that Block has? ...
István Zachar's user avatar
25 votes
1 answer
340 views

StringCases is Confused with Patterns in Version 10.0.1

Bug introduced in 10.0.1 and fixed in 10.0.2 I observed the following with StringCases when trying to use rules/patterns. Here is a screenshot of the behavior: ...
RunnyKine's user avatar
  • 33.1k
24 votes
4 answers
3k views

How to program a F::argx message?

How useful is it to program a user-built function in a package to produce a red warning message F::argx if you give the wrong number of arguments to that function? ...
Hp Radojewski Schäfer Von's user avatar
24 votes
1 answer
3k views

What is available for editing Mathematica source code with Emacs?

I can find several Emacs libraries for Mathematica, but I'm not aware of a clear favourite, a definitive list, or of a library which is actively maintained and developed. None of these appear to be in ...
Ian Hinder's user avatar
  • 2,125
19 votes
1 answer
175 views

Why does setting SyntaxInformation add a definition to DefaultValues

Before setting any definitions to the symbol f, the DefaultValues of f is empty: ...
QuantumDot's user avatar
  • 19.6k
18 votes
3 answers
2k views

How can one define an infix operator with an arbitrary unicode character?

You can setup "UsefulFunction[a, b]" to use custom infix notation "a ↔ b" as follows: ...
M.R.'s user avatar
  • 31.4k
14 votes
2 answers
4k views

Why is this semicolon in red?

I have a piece of code that works well, but when I put a semicolon after a plotting statement, the semicolon appears in red. What's the error?
Mika Ike's user avatar
  • 3,241
14 votes
1 answer
1k views

High Contrast Syntax-Highlighting

I have a neurological disorder which causes me to have migraines if I look at a white computer screen. To combat this, I have put the following at the top of all of my Mathematica notebooks: ...
user26807's user avatar
  • 163
14 votes
1 answer
520 views

SyntaxInformation: take allowed options from multiple symbols – possible?

Suppose I have a function like Options[f] = {foo -> 1}; f[opt : OptionsPattern[{f,g}]] := h@g[Sequence @@ FilterRules[{opt}, Options[g]]] I purposefully do ...
Szabolcs's user avatar
  • 235k
14 votes
1 answer
817 views

Saving a notebook as a $\LaTeX$ file, with syntax highlighting preserved

How can I save a notebook as a $\LaTeX$ file, while preserving the syntax highlighting (such as input/output boxes)?
victor's user avatar
  • 141
12 votes
2 answers
223 views

Customize syntax highlighting for a particular symbol

the comma in Chinese is different from that in English. But they are too similar. correct English comma incorrect Chinese comma As a non-English user, we have to switch the input quite often. If I ...
matheorem's user avatar
  • 17.1k
12 votes
1 answer
228 views

Is there a syntax coloring type that highlights only when not in a list?

How do I define the syntax coloring of local variable of function myfunc so that it only colors the variable that is not in a ...
QuantumDot's user avatar
  • 19.6k
12 votes
1 answer
206 views

Syntax information "ArgumentsPattern" for function of function?

Is is possible to write SyntaxInformation of "ArgumentsPattern" for functions of the form: ...
QuantumDot's user avatar
  • 19.6k
11 votes
1 answer
215 views

Syntax information for pure functions

Mathematica's help on SyntaxInformation does not rule out syntax information for pure functions. SyntaxInformation[f] gives information used to generate syntax coloring and other advisories when f[…...
Hector's user avatar
  • 6,428
11 votes
2 answers
260 views

How to correctly implement in a new function the scoping behavior of Table, Sum and other commands that use Block to localize iterators?

It is documented that "Block is automatically used to localize values of iterators in iteration constructs such as Do, Sum, and Table." Therefore the dummy index (iterator) in a Sum is shielded ...
MaTECmatica's user avatar
11 votes
1 answer
240 views

Proper Syntax highlighting for multi-argument With?

For the case of Block and Module one can choose to define values in the body for the variable names being scoped. So there is no ...
user13892's user avatar
  • 9,363
10 votes
1 answer
622 views

Syntax Highlighting for Mathematica on a Blog

Every once in a while I want to paste Mathematica code on my blog. When I do, I would like it to be somewhat readable, and it would be nice to have syntax highlighting. So far all my searches have ...
vlsd's user avatar
  • 203
9 votes
2 answers
3k views

automatic coloring of function names

Usually, when I define a function and then use it later, the function name is colored in black. But every once in a while, the function color is blue, both in its definition and when I use it later. ...
user avatar
9 votes
1 answer
396 views

No Syntax Highlighting of Package Functions

Lately, my installation of Mathematica has decided not to highlight any symbols loaded from packages. The picture below is a good representation of this: where after loading both ...
rcollyer's user avatar
  • 34k
9 votes
1 answer
539 views

Is it possible to make a custom syntax coloring for "=", "==", and "==="?

I have made this type mistake so many times: Which[a=b,expr1,True,expr2] as opposed to the intended but still correct syntax ...
Craig Carter's user avatar
  • 4,384
9 votes
2 answers
383 views

Wolfram workbench syntax highlighting for local variables inside compile

Lately I've been working quite a lot with Compile. I also started using Wolfram Workbench. So a natural question arises: Is it possible to have syntax ...
Ajasja's user avatar
  • 13.6k
9 votes
1 answer
1k views

Solarized stylesheet and other goodies. Feedback welcome!

I was inspired by this post so I've made a Solarized stylesheet after mucking around with the text options and asking stupid questions on here. I know you can change the syntax highlighting by running ...
seismatica's user avatar
  • 5,101
9 votes
1 answer
253 views

Automatization of SyntaxInformation and argx?

Does anybody have a good way to automate the setting of SyntaxInformation for any custom function? I have a ton of functions for which I want to set SyntaxInformation, and doing it by hand seems a ...
Teake Nutma's user avatar
  • 5,981
8 votes
3 answers
580 views

Syntax highlighting in text cells

I want to write some documentation for a notebook using text cells. Now, I can select parts of the text within such a text cell and set its style to "Input". This does change its font, but there is no ...
Berg's user avatar
  • 1,059
8 votes
2 answers
1k views

Is it possible to change the fontsize when printing a notebook in the working environment?

I want to print a notebook that owns syntax color,I use the Szabolcs's method SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"] Then I can ...
xyz's user avatar
  • 605
8 votes
1 answer
119 views

Does the syntax coloring I see indicate a real problem?

I need a behaviour provided by: x = 2; Block[{x = HoldForm[x]}, x] x FrontEnd marks ...
Kuba's user avatar
  • 137k
8 votes
2 answers
558 views

How to Enable Syntax Coloring of Pattern Match Variable Only (i.e. Without Coloring any Associated Pattern)?

Syntax coloring for the following function definition foo[x_List] := ... will color green (and italicize by default) the argument name ...
StackExchanger's user avatar
7 votes
2 answers
153 views

Nested list of patterns in SyntaxInformation "ArgumentsPattern"

I have a function with the following input structure: f[{{a1, n1}, {a2, n2}...}, {i1, i2,...}] The first argument is a List ...
QuantumDot's user avatar
  • 19.6k
7 votes
1 answer
462 views

Syntax Highlighting for WL files in Atom/Sublime?

What packages do people use for syntax highlighting in Atom, Sublime Text 3, etc?
M.R.'s user avatar
  • 31.4k
7 votes
1 answer
174 views

Update/refresh notebook variable color on clear

By default, Mathematica displays variable names already assigned as black while new variables are displayed in blue. When executing Clear["Global`*"], variables ...
egwene sedai's user avatar
  • 2,355
7 votes
1 answer
150 views

How to add a custom syntax error check

When Mathematica encounters a syntax error like a./b it generates a red bracket and highlights offending symbols with yellow background. I would like to add some ...
Ray Shadow's user avatar
  • 7,816
6 votes
4 answers
221 views

Output code not highlighted when used as input

I have reported this issue: [CASE:3389542] Today, I accidentally found what I believe is an unwanted feature of the front-end, where input code is not appropriately highlighted and the dynamic ...
halirutan's user avatar
  • 113k
6 votes
2 answers
165 views

How to prevent front end from suggesting Symbol option names (when actually String), and from adding them to Global` context

Help! I am writing a package with a function which takes lots and lots of different options which are Strings. When used, the front end autocompletion is ...
QuantumDot's user avatar
  • 19.6k
6 votes
1 answer
168 views

How to detect unused local variables?

I have some code (that I did not write) that has many unused local variables in Modules. I would like to clean this up. Is there any automated way to do this or to make it more clear that a local ...
Kvothe's user avatar
  • 4,387
6 votes
1 answer
169 views

How to recognize variables like built-in functions?

Many built-in functions can recognize variables. For example, function 'Table' makes its iterator change color. How can I implement a function that has a similar behavior? In this function, I can pass ...
Louis Yu's user avatar
  • 857
6 votes
1 answer
137 views

Odd colourization for FourierParameters. UI bug?

The Mathematica UI colourizes the FourierParameters in the following ...
Peeter Joot's user avatar
  • 6,398
5 votes
2 answers
358 views

Syntax highlighting conflict

I'm trying to syntax highlight this expression: x=$\sqrt{\pi }$//N and from various sources I've learned that x (the assigned symbol) belongs to context Global while the Pi and N belongs to System. So ...
seismatica's user avatar
  • 5,101
5 votes
2 answers
751 views

Why does the syntax highlighter color a local symbol red inside DynamicModule?

I am adding a Module inside DynamicModule here is an example (thanks to @rm-rf for this simple example) ...
Nasser's user avatar
  • 143k
5 votes
1 answer
230 views

Incorrect syntax highlighting? "Variables made special by use in arguments" not working

This example is obviously not useful on its own, but it will cover everything I actually need to know for a more complicated function I'm making. The example is to recreate the ...
Lucas Mumbo's user avatar
5 votes
1 answer
152 views

Dynamic InputField with syntax highlighting?

I'm trying to create a notebook where a user can enter a Mathematica expression, and its syntax is analyzed (number of tokens, compressed size, etc.). Trying this answer, ...
lirtosiast's user avatar
5 votes
3 answers
245 views

How can I make a stylesheet where inline cells are styled like input cells?

How can I make a stylesheet where inline cells are styled like input cells? By "similar", I mean the same font and syntax highlighting. I have even tried copying all settings from ...
Naitree's user avatar
  • 1,235
5 votes
1 answer
113 views

How to set "SymbolContextStyles" for `$Context` symbols?

How to change the font colour of symbols defined in the current context (e.g. $Context) from black to some other colour, say purple? There is a ...
Edmund's user avatar
  • 42.2k