Giter VIP home page Giter VIP logo

Comments (6)

muzimuzhi avatar muzimuzhi commented on August 14, 2024

See https://tex.stackexchange.com/questions/294362/use-fira-code-font-with-ligatures-in-code-listings

from minted.

duskmoon314 avatar duskmoon314 commented on August 14, 2024

See tex.stackexchange.com/questions/294362/use-fira-code-font-with-ligatures-in-code-listings

I have already tried this and still have the same problem. So I assume it has something to do with minted. BTW, this definitely works when using verbatim alone.

from minted.

muzimuzhi avatar muzimuzhi commented on August 14, 2024

Then please provide a complete (and if possible, minimal) example, not code snippet with screenshot1. And you should mention what you tried and what you got, no matter the result is negative or partial.

Footnotes

  1. Please never ever post images of code. --- daleif (link)

from minted.

gpoore avatar gpoore commented on August 14, 2024

The linked answer involves multiple steps. The version toward the end uses \def\verbatim@nolig@list{}. This is worth trying if you haven't already.

One additional factor that may be relevant: Pygments, which minted uses to do the actual highlighting, converts >=> into \PYGZgt{}=\PYGZgt{} in the highlighted LaTeX output, where the Pygments style file defines \def\PYGZgt{\char`\>}. It's possible \PYGZgt needs to be redefined.

from minted.

muzimuzhi avatar muzimuzhi commented on August 14, 2024

The following setting works for me, with fira code v3.2v6.2 and a latest mactex 2022, compiled either with xelatex or lualatex.

\setmonofont[
  Contextuals={Alternate},
  CharacterVariant={25,32}
]{Fira Code}

\def\verbatim@nolig@list{}%
\ifdefined\directlua
  \automatichyphenmode=2\relax
\fi
Full example
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec}

\setmonofont[
  Contextuals={Alternate},
  % ligatures `.-` and `.=` require otf features cv25 and cv32, respectively
  % see https://github.com/tonsky/FiraCode, README
  CharacterVariant={25,32}
]{Fira Code Retina} % one of six weights of Fira Code, just to get glyphs a bit bolder 

\usepackage{minted}
\makeatletter
\apptocmd\verbatim@font
  {%
    \def\verbatim@nolig@list{}%
    \ifdefined\directlua
      % see https://github.com/gpoore/fvextra/issues/14
      \automatichyphenmode=2\relax
    \fi
  }
  {}{\PatchFailed}
\makeatother

\begin{document}

\begin{minted}{haskell}
m1 >=> m2
\end{minted}

% see https://tex.stackexchange.com/a/294369
\begin{verbatim}
           .= .- := =:=
        == != === !== =/=

    <<- <-- <- <-> -> --> ->>
<=< <<= <==    <=> => ==> =>> >=>
    >>= >>- >-     -< -<< =<<
        <~~ <~ ~~~ ~> ~~>

     <<< << <= <>  >= >> >>>
            <| <|> |>

            <$ <$> $>
            <+ <+> +>
            <* <*> *>

       \\ \\\ {- -} // ///
          /* /** **/ */ 
      </ <!-- www  --> />
      0xF  9:45  m-x *ptr

       ;; ;;; :: ::: !! !!!
       ?? ??? %% %%% && &&& 
       || ||| .. ... ..< []
       -- --- ++ +++ ** ***

          ~= ~- -~ =~ ~@
        ^= ?= /= /== |= ||=
           ## ### ####
         #{ #[ #( #? #_ #_(


a*b a*A B*b A*B *a *A a* A*
a-b a-A B-b A-B -a -A a- A-
a+b a+A B+b A+B +a +A a+ A+
a:b a:A B:b A:B :a :A a: A:
\end{verbatim}
\end{document}

image

Some links

from minted.

duskmoon314 avatar duskmoon314 commented on August 14, 2024

Then please provide a complete (and if possible, minimal) example, not code snippet with screenshot1. And you should mention what you tried and what you got, no matter the result is negative or partial.

Sorry, my fault.

I have tried to make a minimal example and I found out the main problem is using ctex instead of fontspec to write in Chinese. FiraCode works well in the minted environment, even without using \def\verbatim@nolig@list{}.

Sorry for my bother. Thanks.

from minted.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.