GithubHelp home page GithubHelp logo

Use with FiraCodeStyle about jlcode HOT 8 CLOSED

wg030 avatar wg030 commented on June 2, 2024
Use with FiraCodeStyle

from jlcode.

Comments (8)

wg030 avatar wg030 commented on June 2, 2024

Hey gipert,

you can't make it work like this, I guess.
The basic problem is that "FiraCodeStyle" and "jlcodestyle" both set the "literate" attribute of the listings package. However the listings package is designed in such a way that if one attribute is set by a style and then the same attribute is set by another style, the atrribute will simply be overwritten .
However you could easily copy the literates from the FiraCodeStyle package to the jlcode package or vice versa so that all literates will be loaded.

from jlcode.

gipert avatar gipert commented on June 2, 2024

I tried to merge jlcode and lstfiracode. It compiles but ligatures are still not displayed. I prepared a MWE:

https://gist.github.com/gipert/7fcad4d2aafb9b2500da13d2cee38b5e

(to be compiled with XeLaTeX)

I would be incredibly grateful if you could help me figure out what's going on here...

from jlcode.

wg030 avatar wg030 commented on June 2, 2024

@gipert
I looked at your MWE, but I could not really figure out what happens either.
However I were you I would probaly go the other way round now since it's the ligatures that are not displayed.
So start with the lstfiracode package alone, make your MWE show everything as expected and then add piece by piece of the the things you need form the jlcode package. Maybe this way you can figure out when the ligatures are not shown anymore and we can then identify the root of the problem.

from jlcode.

gipert avatar gipert commented on June 2, 2024

Will do 👍 thanks

from jlcode.

wg030 avatar wg030 commented on June 2, 2024

@gipert 👍 great!
Good Luck and if you make it, please share your solution here so that people with the same problem will know how to handle it!

from jlcode.

wg030 avatar wg030 commented on June 2, 2024

@gipert
Good news for you! While updating the package I checked all issues again, also yours, and I have now found out what happens here. The general problem is that the order of literates is also important and must be respected. Since the jlcode package literates for example =, < or > and these characters are parts of those characters literated by firacode we got into trouble.
Long story short, you must add the firacode literates at the end of jlcodeopstyle. That's all you need to modify in the jlcode package. All the other stuff from the lstfiracode package refers to the verbatim option and is not needed unless you want to also use the verbatim environment, which you don't in you MWE. But if you need it just modify it like you did before.

So just set the literates like this

\lstdefinestyle{jlcodeopstyle}{%
opliterate=*
%
% julia's operators
%
{\$}{{\opc{\$}}}{1} {!}{{\opc{!}}}{1} {\%}{{\opc{\%}}}{1} {&}{{\opc{\&}}}{1}
{’}{{\opc{’}}}{1} {(}{{\opc{(}}}{1} {)}{{\opc{)}}}{1} {*}{{\opc{*}}}{1}
{+}{{\opc{+}}}{1} {,}{{\opc{,}}}{1} {-}{{\opc{-}}}{1} {.}{{\opc{.}}}{1}
{/}{{\opc{/}}}{1} {:}{{\opc{:}}}{1} {;}{{\opc{;}}}{1} {<}{{\opc{<}}}{1}
{=}{{\opc{=}}}{1} {>}{{\opc{>}}}{1} {?}{{\opc{?}}}{1} {[}{{\opc{[}}}{1}
{\\}{{\opc{\lstum@backslash}}}{1} {]}{{\opc{]}}}{1} {^}{{\opc{\^{}}}}{1}
{\{}{{\opc{\{}}}{1} {|}{{\opc{|}}}{1} {\}}{{\opc{\}}}}{1}
{~}{{\opc{\textasciitilde{}}}}{1}
%
% julia's numbers
%
{.0}{{\numc{.0}}}{2} {.1}{{\numc{.1}}}{2} {.2}{{\numc{.2}}}{2}
{.3}{{\numc{.3}}}{2} {.4}{{\numc{.4}}}{2} {.5}{{\numc{.5}}}{2}
{.6}{{\numc{.6}}}{2} {.7}{{\numc{.7}}}{2} {.8}{{\numc{.8}}}{2}
{.9}{{\numc{.9}}}{2}
%
{e+0}{{\numc{e+0}}}{3} {e+1}{{\numc{e+1}}}{3} {e+2}{{\numc{e+2}}}{3}
{e+3}{{\numc{e+3}}}{3} {e+4}{{\numc{e+4}}}{3} {e+5}{{\numc{e+5}}}{3}
{e+6}{{\numc{e+6}}}{3} {e+7}{{\numc{e+7}}}{3} {e+8}{{\numc{e+8}}}{3}
{e+9}{{\numc{e+9}}}{3}
%
{0E+}{{\numc{0E+}}}{3} {1E+}{{\numc{1E+}}}{3} {2E+}{{\numc{2E+}}}{3}
{3E+}{{\numc{3E+}}}{3} {4E+}{{\numc{4E+}}}{3} {5E+}{{\numc{5E+}}}{3}
{6E+}{{\numc{6E+}}}{3} {7E+}{{\numc{7E+}}}{3} {8E+}{{\numc{8E+}}}{3}
{9E+}{{\numc{9E+}}}{3}
%
{e-0}{{\numc{e-0}}}{3} {e-1}{{\numc{e-1}}}{3} {e-2}{{\numc{e-2}}}{3}
{e-3}{{\numc{e-3}}}{3} {e-4}{{\numc{e-4}}}{3} {e-5}{{\numc{e-5}}}{3}
{e-6}{{\numc{e-6}}}{3} {e-7}{{\numc{e-7}}}{3} {e-8}{{\numc{e-8}}}{3}
{e-9}{{\numc{e-9}}}{3}
%
{0E-}{{\numc{0E-}}}{3} {1E-}{{\numc{1E-}}}{3} {2E-}{{\numc{2E-}}}{3}
{3E-}{{\numc{3E-}}}{3} {4E-}{{\numc{4E-}}}{3} {5E-}{{\numc{5E-}}}{3}
{6E-}{{\numc{6E-}}}{3} {7E-}{{\numc{7E-}}}{3} {8E-}{{\numc{8E-}}}{3}
{9E-}{{\numc{9E-}}}{3}
%
% Fira Code
%
{www}{{\opc{www}}}{3} {**}{{\opc{**}}}{2} {***}{{\opc{***}}}{3}
{*>}{{\opc{*>}}}{2} {::}{{\opc{::}}}{2} {:::}{{\opc{:::}}}{3}
{:=}{{\opc{:=}}}{2} {!!}{{\opc{!!}}}{2} {!=}{{\opc{!=}}}{2}
{!==}{{\opc{!==}}}{3} {--}{{\opc{--}}}{2} {---}{{\opc{---}}}{3}
{-->}{{\opc{-->}}}{3} {->}{{\opc{->}}}{2} {->>}{{\opc{->>}}}{3}
{-<}{{\opc{-<}}}{2} {-<<}{{\opc{-<<}}}{3} {-~}{{\opc{-\textasciitilde}}}{2}
{\#\{}{{\opc{\#\{}}}{2} {\#[}{{\opc{\#[}}}{2} {\#\#}{{\opc{\#\#}}}{2}
{\#\#\#}{{\opc{\#\#\#}}}{3} {\#\#\#\#}{{\opc{\#\#\#\#}}}{4}
{\#(}{{\opc{\#(}}}{2} {\#?}{{\opc{\#?}}}{2} {\#_}{{\opc{\#\_}}}{2}
{\#_(}{{\opc{\#\_(}}}{3} {.-}{{\opc{.-}}}{2} {.=}{{\opc{.=}}}{2}
{..}{{\opc{..}}}{2} {..<}{{\opc{..<}}}{3} {...}{{\opc{...}}}{3}
{?=}{{\opc{?=}}}{2} {??}{{\opc{??}}}{2} {/=}{{\opc{/=}}}{2}
{/==}{{\opc{/==}}}{3} {/>}{{\opc{/>}}}{2} {\&\&}{{\opc{\&\&}}}{2}
{||}{{\opc{||}}}{2} {||=}{{\opc{||=}}}{3} {|=}{{\opc{|=}}}{2}
{|>}{{\opc{|>}}}{2} {^=}{{\opc{\textasciicircum=}}}{2} {$>}{{\opc{\$>}}}{2}
{++}{{\opc{++}}}{2} {+>}{{\opc{+>}}}{2} {=:=}{{\opc{=:=}}}{3}
{==}{{\opc{==}}}{2} {===}{{\opc{===}}}{3} {==>}{{\opc{==>}}}{3}
{=>}{{\opc{=>}}}{2} {=>>}{{\opc{=>>}}}{3} {=<<}{{\opc{=<<}}}{3}
{=/=}{{\opc{=/=}}}{3} {>-}{{\opc{>-}}}{2} {>=}{{\opc{>=}}}{2}
{>=>}{{\opc{>=>}}}{3} {>>}{{\opc{>>}}}{2} {>>-}{{\opc{>>-}}}{3}
{>>=}{{\opc{>>=}}}{3} {>>>}{{\opc{>>>}}}{3} {<*}{{\opc{<*}}}{2}
{<*>}{{\opc{<*>}}}{3} {<|}{{\opc{<|}}}{2} {<|>}{{\opc{<|>}}}{3}
{<$}{{\opc{<\$}}}{2} {<$>}{{\opc{<\$>}}}{3} {<!--}{{\opc{<!--}}}{4}
{<-}{{\opc{<-}}}{2} {<--}{{\opc{<--}}}{3} {<->}{{\opc{<->}}}{3}
{<+}{{\opc{<+}}}{2} {<+>}{{\opc{<+>}}}{3} {<=}{{\opc{<=}}}{2}
{<==}{{\opc{<==}}}{3} {<=>}{{\opc{<=>}}}{3} {<=<}{{\opc{<=<}}}{3}
{<>}{{\opc{<>}}}{2} {<<}{{\opc{<<}}}{2} {<<-}{{\opc{<<-}}}{3}
{<<=}{{\opc{<<=}}}{3} {<<<}{{\opc{<<<}}}{3} {<~}{{\opc{<\textasciitilde}}}{2}
{<~~}{{\opc{<\textasciitilde\textasciitilde}}}{3} {</}{{\opc{</}}}{2}
{~@}{{\opc{\textasciitilde @}}}{2} {~-}{{\opc{\textasciitilde-}}}{2}
{~=}{{\opc{\textasciitilde=}}}{2} {~>}{{\opc{\textasciitilde>}}}{2}
{~~}{{\opc{\textasciitilde\textasciitilde}}}{2}
{~~>}{{\opc{\textasciitilde\textasciitilde>}}}{3} {\%\%}{{\opc{\%\%}}}{2}
{<==>}{{\opc{<==>}}}{4} {<||}{{\opc{<||}}}{3} {<|||}{{\opc{<|||}}}{4}
{|||>}{{\opc{|||>}}}{4} {</>}{{\opc{</>}}}{3}
{<~>}{{\opc{<\textasciitilde>}}}{3} {<-<}{{\opc{<-<}}}{3} {>->}{{\opc{>->}}}{3}
{=!=}{{\opc{=!=}}}{3} {+++}{{\opc{+++}}}{3} {||>}{{\opc{||>}}}{3}
{_|_}{{\opc{\_|\_}}}{3} {..=}{{\opc{..=}}}{3} {!!.}{{\opc{!!.}}}{3}
{::=}{{\opc{::=}}}{3} {<:}{{\opc{<:}}}{2} {>:}{{\opc{>:}}}{2}
{|-}{{\opc{|-}}}{2} {|]}{{\opc{|]}}}{2} {|\}}{{\opc{|\}}}}{2}
{__}{{\opc{\_\_}}}{2} {?.}{{\opc{?.}}}{2} {?:}{{\opc{?:}}}{2}
{.?}{{\opc{.?}}}{2} {\#=}{{\opc{\#=}}}{2} {\#!}{{\opc{\#!}}}{2}
{\#:}{{\opc{\#:}}}{2} {-|}{{\opc{-|}}}{2} {:<}{{\opc{:<}}}{2}
{:>}{{\opc{:>}}}{2} {]\#}{{\opc{]\#}}}{2} {[|}{{\opc{[|}}}{2}
{\{|}{{\opc{\{|}}}{2}
}

in the jlcode package and your MWE

%! TEX program = xelatex

\documentclass[11pt,a4paper,twoside]{report}

% font
\usepackage[english]{babel}
\usepackage[LGR,T1]{fontenc}
\usepackage{fontspec}
\setmonofont{Fira Code}[Contextuals=Alternate, Scale=MatchLowercase]
\usepackage[theme=default-plain, usecourier=false]{jlcode} % this must be loaded before unicode-math
\usepackage[lining]{ebgaramond}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\setmathfont{Garamond-Math.otf}[StylisticSet={7,8}]

\begin{document}
Example equation
\[
  \log \mathcal{L}(\theta) = \sum_n \log M(t_n, \theta) - \int M(t, \theta)dt
\]
\begin{lstlisting}
    # pre-defined (log)fitness functions
    logf_dict = Dict(
        :cash => (N_k, T_k) -> N_k * log(N_k/T_k)
    )
\end{lstlisting}
\end{document}

will work exactly they way you want it to work.
Note that I did not add this firacode literates to the jlcode package here because I don't want to overload the lstlisings engine with too many literates that are not needed.

from jlcode.

gipert avatar gipert commented on June 2, 2024

That's great! Many thanks for looking into this.

from jlcode.

wg030 avatar wg030 commented on June 2, 2024

@gipert
You are welcome! Note that I just changed some naming again.
You should call the package with \usepackage[theme=default-plain, usecourier=false]{jlcode} now!
Regards

from jlcode.

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.