3
$\begingroup$

I would like to wrap double-struck brackets around variables for notation purposes only. For instance [[X]] should display as the first image below. However, these brackets are reserved for the built-in function Part.

At the moment, I use angle brackets and then replace these with the new ones via MaTeX). I apply this to lists of expressions involving elements as ⟨XY⟩ -> ⟨X⟩ ⟨Y⟩, where XY, X and Y are graphs:

(⟨XY⟩ -> ⟨X⟩ ⟨Y⟩) /. ⟨x_⟩ :> 
  GraphicsRow[{MaTeX["\\llbracket"], x, MaTeX["\\rrbracket"]}, 
   Scaled[.01], Method -> {"ShrinkWrap" -> True}, ImageSize -> 40]

However, as shown in the second image, there are alignment and scaling issues. If the double-struck brackets are defined as a new notation, I could use instead

(⟨XY⟩ -> ⟨X⟩ ⟨Y⟩) /. ⟨x_⟩ :> [[x]]

which would keep XY, X and Y consistent with their original alignment and scaling.

double-struck brackets 1

double-struck brackets 2

$\endgroup$
8
$\begingroup$

One way of doing this is to use $Preprint:

First define the variables you want to print with double brackets. Then define a $PrePrint function:

vars = {a, b, c};

$PrePrint = 
  With[{v = 
     Thread[vars -> ("\[LeftDoubleBracket]" <> ToString[#] <> 
           "\[RightDoubleBracket]" &) /@ vars]}, # /. v &];

Here is an example:

Sqrt[a] + b^3 - Sin[c]

enter image description here

$\endgroup$
4
$\begingroup$

Via the Notation package, one can define a new command:

Needs["Notation`"];
Notation[ParsedBoxWrapper[
   RowBox[{"\[LeftDoubleBracket]", "x_", 
     "\[RightDoubleBracket]"}]]\[DoubleLongLeftArrow]ParsedBoxWrapper[
   RowBox[{"ll[", "x_", "rr]"}]]]

which is displayed with the notation palette as

palette2

and which gives the result

result2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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