In my editor I have liguatures enabled that turn || to a \/ symbol and lambda to a λ. I copy-paste a lot of code into the minted environment and its a shame that these do not carry over. Is it possible to tell minted to replace all occurances of || with the logical or symbol and all occurances of lambda with \lambda for example?

I found out that using fontspec and FiraCode translates the -> to the character arrow but this does not seem very configurable.

  • Have you seen tex.stackexchange.com/q/294362 ?
    – Thérèse
    Oct 19, 2021 at 0:43
  • I probably shouldn't have mentioned FiraCode because that is not the direction I want to go. I don't want to replace character sequences with single unicode characters. I would prefer if I could tell latex to replace some sequences of characters (eg ->) with other sequences of characters (eg \to).
    – fakedrake
    Oct 19, 2021 at 1:49
  • @fakedrake Will be tricky. Yes, an expl3 replace or regex can do a substitution, and minted when doing the verbatim environment can escape to latex code, but (manual, p24): "Note that when math is used inside escapes, any active characters beyond those that are normally active in verbatim can cause problems." and then links to: tex.stackexchange.com/questions/223876/… Unrelated: Interestingly, a % in a tex minted typesets the line as latex, but you have to switch to \rmfamily since monospace doesn't have ligatures.
    – Cicada
    Oct 19, 2021 at 9:41

1 Answer 1


It is a type of meta-processing.

"Telling" is where the effort is.

Example of doing expl3 replace by escaping out of minted's verbatim environment and applying a replace-command:


Using unique identifiers, and going directly to (unicode) math glyphs, makes maintenance easier and avoids minted's math-mode glitching.

But probably easier just to type x ∈ ℜ in a unicode-math space in the first place, without needing to use a lookup command at all, and switching fonts automatically, maybe in an environment-in-an-environment (somehow). Fancyvrb's verbatim environment keeps getting in the way.


\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\setmonofont{Noto Sans Mono}
\newfontface\mymfont{XITS Math}


\tl_new:N \l_mytrans_tl 
\NewDocumentCommand { \translit } { m } {%
        \tl_set:Nn \l_mytrans_tl { #1 }
        \tl_use:N \l_mytrans_tl

%---- Environments
\NewDocumentEnvironment{translite}{ +b }
        \tl_set:Nn \l_mytrans_tl { #1 }
        \tl_use:N \l_mytrans_tl
{ }

\tl_replace_all:Nnn \l_mytrans_tl { mlambda }  {  $\lambda$  } 
\tl_replace_all:Nnn \l_mytrans_tl { xlambda }  {  \textmymath{𝜆}  } % U+1D706 MATHEMATICAL ITALIC SMALL LAMDA
\tl_replace_all:Nnn \l_mytrans_tl { xreal }  {\textmymath{ℜ} } % U+211C BLACK-LETTER CAPITAL R : real part
\tl_replace_all:Nnn \l_mytrans_tl { xelementof }  { \textmymath{∈} } % U+2208 ELEMENT OF
\tl_replace_all:Nnn \l_mytrans_tl { xmapsto }  { \textmymath{↦} } % U+21A6 RIGHTWARDS ARROW FROM BAR : z notation maplet



xlambda $\mapsto$ \translit{xlambda}

% This is a TeX comment but is not disregarded because it's inside
%| {\rmfamily ffi ffl >> -- --- } | font ligatures yes, TeX ligatures no.
| {\rmfamily xlambda = \translit{xlambda} } |

| {\translit{x xmapsto y xelementof xreal}}|


Dont use $$ in \LaTeXe!  % It's weird!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .