I would like to to write in math mode using tt font and everything ok, but brackets. The next code
$ \mathtt{[x + y]} $
get
but i would like to get
It can be done by some additional commands
$ \mathtt{\texttt{[}x + y\texttt{]}} $
Is there any way get desirable result without any additions?
I try to write definition for active symbol
\def\lbr{[}
\begingroup
\catcode`[=\active
\gdef[{\texttt{[}}
\endgroup
\AtBeginDocument{\mathcode`[="8000}
but it looks like replacement performs recursively.
Another way i think that it is necessary to change mathcode for [ to mathcode of letters but do not find solution.
Addition
The solution
\def\lbr{[}
\begingroup
\catcode`[=\active
\gdef[{\texttt{\lbrack}}
\endgroup
\AtBeginDocument{\mathcode`[="8000}
works correctly with \gdef[{\texttt{\lbrack}}




\ttfont, it's not likely to look a lot different than if your simply set it all as\texttt{[x + y]}. you might try that to see if it's acceptable. – barbara beeton Sep 20 '17 at 16:18\ttintegral. (would have been useful to have that requirement in the question.) if a suitable font can be found that is accessed by unicode, it might still be possible to treat it as\textttwithutf8encoding. but this too falls apart as soon as you want non-numeric superscripts or subscripts -- that really does need math markup. i have to leave that to someone else to address. – barbara beeton Sep 20 '17 at 17:00mathastextit will do that (see1.8 Extended scope of the math alphabets commandsin its manual), il you emit\MTnonlettersobeymathxx. – Sep 20 '17 at 17:19\Mathttdefined bymathastext! you can use this withmathastextin subdued mode, as explained at the https://tex.stackexchange.com/questions/119879/math-symbols-in-tt-font that you found! – Sep 21 '17 at 18:03