Questions tagged [syntax-highlighting]
Questions about highlighting for Mathematica input in the Mathematica front-end, and Wolfram Workbench.
35
questions
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 ...
44
votes
2
answers
5k
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 ...
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 ...
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? ...
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:
...
77
votes
3
answers
3k
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 ...
44
votes
3
answers
5k
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 ...
14
votes
1
answer
506
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 ...
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?
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 ...
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 ...
5
votes
2
answers
351
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 ...
9
votes
1
answer
393
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 ...
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 ...
7
votes
1
answer
172
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 ...
5
votes
2
answers
743
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)
...
5
votes
3
answers
239
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 ...
1
vote
1
answer
518
views
Module and Manipulate: Why the Red Highlighting? [duplicate]
If I define a function that returns a Manipulate object, and the Manipulate has a local variable inside of it, the local ...
0
votes
0
answers
212
views
My "N" turned red randomly [duplicate]
For some reason my N function showed up in red even though I haven't noticed it in that color before. The color actually makes the code much more readable but I just don't know if I should be alarmed ...
31
votes
1
answer
529
views
What is ColorEqualSigns and how does one use it?
Bug introduced in 9.0.1 or earlier and persists in 13.2.1
I'm setting up the SyntaxInformation for a package I'm writing and I'm struggling to understand what the <...
9
votes
1
answer
250
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 ...
14
votes
1
answer
801
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)?
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:
...
12
votes
1
answer
202
views
Syntax information "ArgumentsPattern" for function of function?
Is is possible to write SyntaxInformation of "ArgumentsPattern" for functions of the form:
...
10
votes
1
answer
616
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 ...
8
votes
2
answers
552
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 ...
8
votes
3
answers
539
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 ...
6
votes
2
answers
153
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 ...
5
votes
1
answer
139
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,
...
5
votes
0
answers
257
views
Syntax colouring when using Symbolize
I need to use symbols with suffixes in order to make my code readable in relation to the Eurocodes. To do this I use Symbolize from the ...
4
votes
1
answer
2k
views
What's the difference between variables with and without a subscript?
If I input $x = a + b$, the $x$, $a$ and $b$ are blue. When I hit Shif+Enter, the $x$ turns black, indicating the kernel now knows this variable. But when I input $x_r = a + b$, and hit Shift+Enter, $...
3
votes
1
answer
107
views
Why does syntax highlighting in `Set` and `Rule` not color pattern names on the RHS?
The mathematica front-end colors x on the right hand side of x_ :> x and f[x_] := x but ...
2
votes
1
answer
187
views
Why are `Control` variables indicated as undefined in the frontend?
Inside Manipulate, symbols defined in controls that are created by hand with Control are given "undefined" syntax coloring. For ...
2
votes
1
answer
170
views
Having variables appear aqua in user defined function [duplicate]
In many of the inbuilt mathematica function, variables appear aqua like in:
However, when creating your own function, variables no longer have that green coloring and are instead colored like an ...
1
vote
0
answers
63
views
Syntax highlighting of RuleDelayed involving Orderless symbols
I am using version 10.0.2
If I set
SetAttributes[ol, Orderless]
Then the following expression appears to be highlighted incorrectly after clicking in it (no ...