I'm trying to format an Association from Mathematica which looks like this:

enter image description here

This is what I have so far, but it doesn't look the same:

\usepackage{graphicx} % for \scalebox macro


$\leftassn 1 \rightarrow a, 2 \rightarrow b \rightassn$

enter image description here

  • “More exactly” means using a monospaced font? – egreg Dec 19 '18 at 10:36
  • @egreg that's a start, I tried that and they still don't look nearly the same. Maybe changing the symbols I chose to kludge together will help... – M.R. Dec 19 '18 at 10:45
  • 2
    @M.R. My point is that when people ask for clarifications in comments, as happened here, you should update your question, not provide more details in comments, as you did above. – Sverre Dec 19 '18 at 20:04
  • 1
    Barring some font choices, how does this look? – Werner Dec 28 '18 at 6:57
  • 1
    On Windows, Mathematica uses consolas; while on Linux/macOS, it uses Source Code Pro. The special symbols, are from Mathematica Mono. – stone-zeng Dec 28 '18 at 7:25

I use Courier New/Consolas/Source Code Pro as well as Mathematica Mono (can be found in the directory of your local installation) to format it:

enter image description here


% Default colors of Mathematica

  Path=C:/Program Files/Wolfram Research/Mathematica/11.3/SystemFiles/Fonts/TrueType/,
  UprightFont=*, BoldFont=*-Bold]


\fontspec{Courier New}[BoldFont=* Bold]\TEST\
\Comment{Courier New}

\Comment{Courier New Bold}


\fontspec{Source Code Pro}[BoldFont=*]\TEST\
\Comment{Source Code Pro}

Note that the spaces are added by hand.

| improve this answer | |
  • Is there some way to add the spaces automatically? – M.R. Dec 28 '18 at 7:52
  • I guess no. To get the correct space, you need use the math mode; the correct font, however, cannot be used (at least easily) in the math mode. I think we need more setup to format the code in LaTeX as in Mathematica. – stone-zeng Dec 28 '18 at 8:09

You can get automatic spacing, but it requires a bit of work. This needs XeLaTeX or LuaLaTeX.

A proof of concept:





  % alphabetical symbols from Consolas
  \Umathcode`"= 7 \symassoc `"
  \Umathcode`α= 7 \symassoc `α
  \Umathcode`β= 7 \symassoc `β
  \Umathcode`,= 6 \symassoc `,
  % other symbols from MathematicaMono
  \Umathcode`→= 3 \symwmmono "F522
  \Umathchardef\openassociation= 4 \symwmmono "F113
  \Umathchardef\closeassociation= 5 \symwmmono "F114


\association{1 → "a",2 → "b"}

\association{1 → "α",2 → "β"}


enter image description here

| improve this answer | |

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.