Weird Vertical Spacing of '*' with Fira Code in Listings












6














I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE:



documentclass{scrartcl}

usepackage{fontspec}
usepackage{xcolor}
usepackage{listings}

newfontfamily{firaseries}{Fira Code}

lstdefinestyle{mStyle}{
language=C++,
basicstyle=footnotesizefiraseries,
commentstyle=color{red}
}

lstset{style=mStyle}

begin{document}
Default font text with *.

firaseries This is text in Fira Code with *.

begin{lstlisting}
Listing text with *.
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


This produces the following output: First PDF Output



As you can see, the * characters are way too low when used in the listing.



In an attempt to fix this issue, I added this line to my style definition:



literate={*}{{firaseries*}}1


This yields the desired vertical position but unfortunately, it creates a new problem: Now the text after a multi-line comment is also red.



Second PDF Output



I would very much appreciate any pointers on how to fix this problem.










share|improve this question
























  • Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
    – Ruixi Zhang
    Dec 12 '18 at 15:43






  • 1




    BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
    – Ruixi Zhang
    Dec 12 '18 at 16:01










  • @RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
    – Leon
    Dec 12 '18 at 16:04










  • Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
    – Ruixi Zhang
    Dec 12 '18 at 16:12
















6














I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE:



documentclass{scrartcl}

usepackage{fontspec}
usepackage{xcolor}
usepackage{listings}

newfontfamily{firaseries}{Fira Code}

lstdefinestyle{mStyle}{
language=C++,
basicstyle=footnotesizefiraseries,
commentstyle=color{red}
}

lstset{style=mStyle}

begin{document}
Default font text with *.

firaseries This is text in Fira Code with *.

begin{lstlisting}
Listing text with *.
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


This produces the following output: First PDF Output



As you can see, the * characters are way too low when used in the listing.



In an attempt to fix this issue, I added this line to my style definition:



literate={*}{{firaseries*}}1


This yields the desired vertical position but unfortunately, it creates a new problem: Now the text after a multi-line comment is also red.



Second PDF Output



I would very much appreciate any pointers on how to fix this problem.










share|improve this question
























  • Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
    – Ruixi Zhang
    Dec 12 '18 at 15:43






  • 1




    BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
    – Ruixi Zhang
    Dec 12 '18 at 16:01










  • @RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
    – Leon
    Dec 12 '18 at 16:04










  • Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
    – Ruixi Zhang
    Dec 12 '18 at 16:12














6












6








6


1





I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE:



documentclass{scrartcl}

usepackage{fontspec}
usepackage{xcolor}
usepackage{listings}

newfontfamily{firaseries}{Fira Code}

lstdefinestyle{mStyle}{
language=C++,
basicstyle=footnotesizefiraseries,
commentstyle=color{red}
}

lstset{style=mStyle}

begin{document}
Default font text with *.

firaseries This is text in Fira Code with *.

begin{lstlisting}
Listing text with *.
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


This produces the following output: First PDF Output



As you can see, the * characters are way too low when used in the listing.



In an attempt to fix this issue, I added this line to my style definition:



literate={*}{{firaseries*}}1


This yields the desired vertical position but unfortunately, it creates a new problem: Now the text after a multi-line comment is also red.



Second PDF Output



I would very much appreciate any pointers on how to fix this problem.










share|improve this question















I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE:



documentclass{scrartcl}

usepackage{fontspec}
usepackage{xcolor}
usepackage{listings}

newfontfamily{firaseries}{Fira Code}

lstdefinestyle{mStyle}{
language=C++,
basicstyle=footnotesizefiraseries,
commentstyle=color{red}
}

lstset{style=mStyle}

begin{document}
Default font text with *.

firaseries This is text in Fira Code with *.

begin{lstlisting}
Listing text with *.
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


This produces the following output: First PDF Output



As you can see, the * characters are way too low when used in the listing.



In an attempt to fix this issue, I added this line to my style definition:



literate={*}{{firaseries*}}1


This yields the desired vertical position but unfortunately, it creates a new problem: Now the text after a multi-line comment is also red.



Second PDF Output



I would very much appreciate any pointers on how to fix this problem.







listings luatex fontspec code






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 12 '18 at 21:43

























asked Dec 12 '18 at 15:03









Leon

335




335












  • Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
    – Ruixi Zhang
    Dec 12 '18 at 15:43






  • 1




    BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
    – Ruixi Zhang
    Dec 12 '18 at 16:01










  • @RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
    – Leon
    Dec 12 '18 at 16:04










  • Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
    – Ruixi Zhang
    Dec 12 '18 at 16:12


















  • Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
    – Ruixi Zhang
    Dec 12 '18 at 15:43






  • 1




    BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
    – Ruixi Zhang
    Dec 12 '18 at 16:01










  • @RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
    – Leon
    Dec 12 '18 at 16:04










  • Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
    – Ruixi Zhang
    Dec 12 '18 at 16:12
















Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
– Ruixi Zhang
Dec 12 '18 at 15:43




Welcome to TeX.SX! If I remembered correctly, the /* and */ are two pairs of characters which have ligatures in Fira Code. I suspect the problem comes from how listings treats the special * character.
– Ruixi Zhang
Dec 12 '18 at 15:43




1




1




BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
– Ruixi Zhang
Dec 12 '18 at 16:01




BTW, simply using literate={*}{*}1 suffices to get the * up. But still no ligature :(
– Ruixi Zhang
Dec 12 '18 at 16:01












@RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
– Leon
Dec 12 '18 at 16:04




@RuixiZhang Oh, that's good to know as well. I do not care about ligatures in this case anyway so it's not too much of an issue for me. :)
– Leon
Dec 12 '18 at 16:04












Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
– Ruixi Zhang
Dec 12 '18 at 16:12




Still, I am searching for a solution that enables Fira Code's ligatures. Here is a comparison between Ulrike Fischer's nice answer and what I intended to work on: i.stack.imgur.com/4CzUM.png
– Ruixi Zhang
Dec 12 '18 at 16:12










2 Answers
2






active

oldest

votes


















3














Although @UlrikeFischer’s answer solves the OP, it is still worth mentioning that there are hidden traps. Consider the following “enhanced” example from the OP:



documentclass{scrartcl}
usepackage{fontspec,xcolor,listings}
newfontfamilyfiraseries{Fira Code}
lstdefinestyle{LeonStyle}{
language=C++,
basicstyle=footnotesizefiraseries,
commentstyle=color{red}
}
lstset{style=LeonStyle}
begin{document}
begin{lstlisting}
Listing text with *.
C++ a<=b c=2-1
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


HiddenProblems



The hyphen-minus symbol is wrong, too. In fact, it is replaced with a math mode minus $-$ by the listings package.





The easiest solution



Don’t load Fira Code via newfontfamily. Instead, load the font via setmonofont and use basicstyle=ttfamily. This signifies Fira Code as a monospaced typeface and prevents listings from replacing certain symbols.



documentclass{scrartcl}
usepackage{fontspec,xcolor,listings}
setmonofont{Fira Code}
lstdefinestyle{LeonStyle}{
language=C++,
basicstyle=footnotesizettfamily,
commentstyle=color{red}
}
lstset{style=LeonStyle}
begin{document}
begin{lstlisting}
Listing text with *.
C++ a<=b c=2-1
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


ttfamily





More elaborate solution



Over the past few days, I have written a small package lstfiracode (shameless plug). It is mainly designed to utilize the Fira Code programming ligatures in the lstlisting environment. If you are using Fira Code, then you probably want the ligatures (otherwise you could just use Fira Mono). Here is how you would implement lstfiracode:



documentclass{scrartcl}
usepackage{fontspec,xcolor,listings}
usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
setmonofont{Fira Code}[Ligatures=Common,Contextuals=Alternate]
lstset{
language=C++,
style=FiraCodeStyle,
basicstyle=footnotesizettfamily,
commentstyle=color{red}
}
begin{document}
begin{lstlisting}
Listing text with *.
C++ a<=b c=2-1
/* This is a comment. */
This should not be red.
end{lstlisting}
end{document}


ligatures



The lstfiracode package is now on CTAN (2018/12/17). It will be available on all the mirrors and the major TeX distributions in the next few days. Enjoy! :)






share|improve this answer































    3














    You can raise the asterix like this:



    documentclass{scrartcl}

    usepackage{fontspec}
    usepackage{xcolor}
    usepackage{listings}

    newfontfamily{firaseries}{Fira Code}

    lstdefinestyle{mStyle}{
    language=C++,
    basicstyle=footnotesizefiraseries,
    commentstyle=color{red}
    }

    lstset{style=mStyle}
    makeatletter
    lst@CCPutMacro
    lst@ProcessOther {"2A}{%
    lst@ttfamily
    {*}% used with ttfamily
    {raisebox{1ex}{textasteriskcentered}}}% used with other fonts
    @emptyz@@empty
    makeatother

    begin{document}
    Default font text with *.

    firaseries This is text in Fira Code with *.

    begin{lstlisting}
    Listing text with *.
    /* This is a comment. */
    This should not be red.
    end{lstlisting}
    end{document}


    Something like this would work too (or you combine it with a raisebox):



    makeatletter
    lst@CCPutMacro
    lst@ProcessOther {"2A}{%
    lst@ttfamily
    {*}% used with ttfamily
    {*}}% used with other fonts
    @emptyz@@empty
    makeatother





    share|improve this answer





















    • This is great, thank you! Although I have no idea why or how this works ... :)
      – Leon
      Dec 12 '18 at 16:02











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464541%2fweird-vertical-spacing-of-with-fira-code-in-listings%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Although @UlrikeFischer’s answer solves the OP, it is still worth mentioning that there are hidden traps. Consider the following “enhanced” example from the OP:



    documentclass{scrartcl}
    usepackage{fontspec,xcolor,listings}
    newfontfamilyfiraseries{Fira Code}
    lstdefinestyle{LeonStyle}{
    language=C++,
    basicstyle=footnotesizefiraseries,
    commentstyle=color{red}
    }
    lstset{style=LeonStyle}
    begin{document}
    begin{lstlisting}
    Listing text with *.
    C++ a<=b c=2-1
    /* This is a comment. */
    This should not be red.
    end{lstlisting}
    end{document}


    HiddenProblems



    The hyphen-minus symbol is wrong, too. In fact, it is replaced with a math mode minus $-$ by the listings package.





    The easiest solution



    Don’t load Fira Code via newfontfamily. Instead, load the font via setmonofont and use basicstyle=ttfamily. This signifies Fira Code as a monospaced typeface and prevents listings from replacing certain symbols.



    documentclass{scrartcl}
    usepackage{fontspec,xcolor,listings}
    setmonofont{Fira Code}
    lstdefinestyle{LeonStyle}{
    language=C++,
    basicstyle=footnotesizettfamily,
    commentstyle=color{red}
    }
    lstset{style=LeonStyle}
    begin{document}
    begin{lstlisting}
    Listing text with *.
    C++ a<=b c=2-1
    /* This is a comment. */
    This should not be red.
    end{lstlisting}
    end{document}


    ttfamily





    More elaborate solution



    Over the past few days, I have written a small package lstfiracode (shameless plug). It is mainly designed to utilize the Fira Code programming ligatures in the lstlisting environment. If you are using Fira Code, then you probably want the ligatures (otherwise you could just use Fira Mono). Here is how you would implement lstfiracode:



    documentclass{scrartcl}
    usepackage{fontspec,xcolor,listings}
    usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
    setmonofont{Fira Code}[Ligatures=Common,Contextuals=Alternate]
    lstset{
    language=C++,
    style=FiraCodeStyle,
    basicstyle=footnotesizettfamily,
    commentstyle=color{red}
    }
    begin{document}
    begin{lstlisting}
    Listing text with *.
    C++ a<=b c=2-1
    /* This is a comment. */
    This should not be red.
    end{lstlisting}
    end{document}


    ligatures



    The lstfiracode package is now on CTAN (2018/12/17). It will be available on all the mirrors and the major TeX distributions in the next few days. Enjoy! :)






    share|improve this answer




























      3














      Although @UlrikeFischer’s answer solves the OP, it is still worth mentioning that there are hidden traps. Consider the following “enhanced” example from the OP:



      documentclass{scrartcl}
      usepackage{fontspec,xcolor,listings}
      newfontfamilyfiraseries{Fira Code}
      lstdefinestyle{LeonStyle}{
      language=C++,
      basicstyle=footnotesizefiraseries,
      commentstyle=color{red}
      }
      lstset{style=LeonStyle}
      begin{document}
      begin{lstlisting}
      Listing text with *.
      C++ a<=b c=2-1
      /* This is a comment. */
      This should not be red.
      end{lstlisting}
      end{document}


      HiddenProblems



      The hyphen-minus symbol is wrong, too. In fact, it is replaced with a math mode minus $-$ by the listings package.





      The easiest solution



      Don’t load Fira Code via newfontfamily. Instead, load the font via setmonofont and use basicstyle=ttfamily. This signifies Fira Code as a monospaced typeface and prevents listings from replacing certain symbols.



      documentclass{scrartcl}
      usepackage{fontspec,xcolor,listings}
      setmonofont{Fira Code}
      lstdefinestyle{LeonStyle}{
      language=C++,
      basicstyle=footnotesizettfamily,
      commentstyle=color{red}
      }
      lstset{style=LeonStyle}
      begin{document}
      begin{lstlisting}
      Listing text with *.
      C++ a<=b c=2-1
      /* This is a comment. */
      This should not be red.
      end{lstlisting}
      end{document}


      ttfamily





      More elaborate solution



      Over the past few days, I have written a small package lstfiracode (shameless plug). It is mainly designed to utilize the Fira Code programming ligatures in the lstlisting environment. If you are using Fira Code, then you probably want the ligatures (otherwise you could just use Fira Mono). Here is how you would implement lstfiracode:



      documentclass{scrartcl}
      usepackage{fontspec,xcolor,listings}
      usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
      setmonofont{Fira Code}[Ligatures=Common,Contextuals=Alternate]
      lstset{
      language=C++,
      style=FiraCodeStyle,
      basicstyle=footnotesizettfamily,
      commentstyle=color{red}
      }
      begin{document}
      begin{lstlisting}
      Listing text with *.
      C++ a<=b c=2-1
      /* This is a comment. */
      This should not be red.
      end{lstlisting}
      end{document}


      ligatures



      The lstfiracode package is now on CTAN (2018/12/17). It will be available on all the mirrors and the major TeX distributions in the next few days. Enjoy! :)






      share|improve this answer


























        3












        3








        3






        Although @UlrikeFischer’s answer solves the OP, it is still worth mentioning that there are hidden traps. Consider the following “enhanced” example from the OP:



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        newfontfamilyfiraseries{Fira Code}
        lstdefinestyle{LeonStyle}{
        language=C++,
        basicstyle=footnotesizefiraseries,
        commentstyle=color{red}
        }
        lstset{style=LeonStyle}
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        HiddenProblems



        The hyphen-minus symbol is wrong, too. In fact, it is replaced with a math mode minus $-$ by the listings package.





        The easiest solution



        Don’t load Fira Code via newfontfamily. Instead, load the font via setmonofont and use basicstyle=ttfamily. This signifies Fira Code as a monospaced typeface and prevents listings from replacing certain symbols.



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        setmonofont{Fira Code}
        lstdefinestyle{LeonStyle}{
        language=C++,
        basicstyle=footnotesizettfamily,
        commentstyle=color{red}
        }
        lstset{style=LeonStyle}
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        ttfamily





        More elaborate solution



        Over the past few days, I have written a small package lstfiracode (shameless plug). It is mainly designed to utilize the Fira Code programming ligatures in the lstlisting environment. If you are using Fira Code, then you probably want the ligatures (otherwise you could just use Fira Mono). Here is how you would implement lstfiracode:



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
        setmonofont{Fira Code}[Ligatures=Common,Contextuals=Alternate]
        lstset{
        language=C++,
        style=FiraCodeStyle,
        basicstyle=footnotesizettfamily,
        commentstyle=color{red}
        }
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        ligatures



        The lstfiracode package is now on CTAN (2018/12/17). It will be available on all the mirrors and the major TeX distributions in the next few days. Enjoy! :)






        share|improve this answer














        Although @UlrikeFischer’s answer solves the OP, it is still worth mentioning that there are hidden traps. Consider the following “enhanced” example from the OP:



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        newfontfamilyfiraseries{Fira Code}
        lstdefinestyle{LeonStyle}{
        language=C++,
        basicstyle=footnotesizefiraseries,
        commentstyle=color{red}
        }
        lstset{style=LeonStyle}
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        HiddenProblems



        The hyphen-minus symbol is wrong, too. In fact, it is replaced with a math mode minus $-$ by the listings package.





        The easiest solution



        Don’t load Fira Code via newfontfamily. Instead, load the font via setmonofont and use basicstyle=ttfamily. This signifies Fira Code as a monospaced typeface and prevents listings from replacing certain symbols.



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        setmonofont{Fira Code}
        lstdefinestyle{LeonStyle}{
        language=C++,
        basicstyle=footnotesizettfamily,
        commentstyle=color{red}
        }
        lstset{style=LeonStyle}
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        ttfamily





        More elaborate solution



        Over the past few days, I have written a small package lstfiracode (shameless plug). It is mainly designed to utilize the Fira Code programming ligatures in the lstlisting environment. If you are using Fira Code, then you probably want the ligatures (otherwise you could just use Fira Mono). Here is how you would implement lstfiracode:



        documentclass{scrartcl}
        usepackage{fontspec,xcolor,listings}
        usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
        setmonofont{Fira Code}[Ligatures=Common,Contextuals=Alternate]
        lstset{
        language=C++,
        style=FiraCodeStyle,
        basicstyle=footnotesizettfamily,
        commentstyle=color{red}
        }
        begin{document}
        begin{lstlisting}
        Listing text with *.
        C++ a<=b c=2-1
        /* This is a comment. */
        This should not be red.
        end{lstlisting}
        end{document}


        ligatures



        The lstfiracode package is now on CTAN (2018/12/17). It will be available on all the mirrors and the major TeX distributions in the next few days. Enjoy! :)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 17 '18 at 20:23

























        answered Dec 17 '18 at 18:52









        Ruixi Zhang

        5,113320




        5,113320























            3














            You can raise the asterix like this:



            documentclass{scrartcl}

            usepackage{fontspec}
            usepackage{xcolor}
            usepackage{listings}

            newfontfamily{firaseries}{Fira Code}

            lstdefinestyle{mStyle}{
            language=C++,
            basicstyle=footnotesizefiraseries,
            commentstyle=color{red}
            }

            lstset{style=mStyle}
            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {raisebox{1ex}{textasteriskcentered}}}% used with other fonts
            @emptyz@@empty
            makeatother

            begin{document}
            Default font text with *.

            firaseries This is text in Fira Code with *.

            begin{lstlisting}
            Listing text with *.
            /* This is a comment. */
            This should not be red.
            end{lstlisting}
            end{document}


            Something like this would work too (or you combine it with a raisebox):



            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {*}}% used with other fonts
            @emptyz@@empty
            makeatother





            share|improve this answer





















            • This is great, thank you! Although I have no idea why or how this works ... :)
              – Leon
              Dec 12 '18 at 16:02
















            3














            You can raise the asterix like this:



            documentclass{scrartcl}

            usepackage{fontspec}
            usepackage{xcolor}
            usepackage{listings}

            newfontfamily{firaseries}{Fira Code}

            lstdefinestyle{mStyle}{
            language=C++,
            basicstyle=footnotesizefiraseries,
            commentstyle=color{red}
            }

            lstset{style=mStyle}
            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {raisebox{1ex}{textasteriskcentered}}}% used with other fonts
            @emptyz@@empty
            makeatother

            begin{document}
            Default font text with *.

            firaseries This is text in Fira Code with *.

            begin{lstlisting}
            Listing text with *.
            /* This is a comment. */
            This should not be red.
            end{lstlisting}
            end{document}


            Something like this would work too (or you combine it with a raisebox):



            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {*}}% used with other fonts
            @emptyz@@empty
            makeatother





            share|improve this answer





















            • This is great, thank you! Although I have no idea why or how this works ... :)
              – Leon
              Dec 12 '18 at 16:02














            3












            3








            3






            You can raise the asterix like this:



            documentclass{scrartcl}

            usepackage{fontspec}
            usepackage{xcolor}
            usepackage{listings}

            newfontfamily{firaseries}{Fira Code}

            lstdefinestyle{mStyle}{
            language=C++,
            basicstyle=footnotesizefiraseries,
            commentstyle=color{red}
            }

            lstset{style=mStyle}
            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {raisebox{1ex}{textasteriskcentered}}}% used with other fonts
            @emptyz@@empty
            makeatother

            begin{document}
            Default font text with *.

            firaseries This is text in Fira Code with *.

            begin{lstlisting}
            Listing text with *.
            /* This is a comment. */
            This should not be red.
            end{lstlisting}
            end{document}


            Something like this would work too (or you combine it with a raisebox):



            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {*}}% used with other fonts
            @emptyz@@empty
            makeatother





            share|improve this answer












            You can raise the asterix like this:



            documentclass{scrartcl}

            usepackage{fontspec}
            usepackage{xcolor}
            usepackage{listings}

            newfontfamily{firaseries}{Fira Code}

            lstdefinestyle{mStyle}{
            language=C++,
            basicstyle=footnotesizefiraseries,
            commentstyle=color{red}
            }

            lstset{style=mStyle}
            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {raisebox{1ex}{textasteriskcentered}}}% used with other fonts
            @emptyz@@empty
            makeatother

            begin{document}
            Default font text with *.

            firaseries This is text in Fira Code with *.

            begin{lstlisting}
            Listing text with *.
            /* This is a comment. */
            This should not be red.
            end{lstlisting}
            end{document}


            Something like this would work too (or you combine it with a raisebox):



            makeatletter
            lst@CCPutMacro
            lst@ProcessOther {"2A}{%
            lst@ttfamily
            {*}% used with ttfamily
            {*}}% used with other fonts
            @emptyz@@empty
            makeatother






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 12 '18 at 15:58









            Ulrike Fischer

            186k7290669




            186k7290669












            • This is great, thank you! Although I have no idea why or how this works ... :)
              – Leon
              Dec 12 '18 at 16:02


















            • This is great, thank you! Although I have no idea why or how this works ... :)
              – Leon
              Dec 12 '18 at 16:02
















            This is great, thank you! Although I have no idea why or how this works ... :)
            – Leon
            Dec 12 '18 at 16:02




            This is great, thank you! Although I have no idea why or how this works ... :)
            – Leon
            Dec 12 '18 at 16:02


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464541%2fweird-vertical-spacing-of-with-fira-code-in-listings%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?