How to enable contextual substitutions in lstlisting? Announcing the arrival of Valued...

Can gravitational waves pass through a black hole?

Where and when has Thucydides been studied?

Does the main washing effect of soap come from foam?

An isoperimetric-type inequality inside a cube

Plotting a Maclaurin series

"Destructive power" carried by a B-52?

What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?

Statistical analysis applied to methods coming out of Machine Learning

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

Centre cell vertically in tabularx

Did any compiler fully use 80-bit floating point?

What is "Lambda" in Heston's original paper on stochastic volatility models?

Problem with display of presentation

Flight departed from the gate 5 min before scheduled departure time. Refund options

How can I list files in reverse time order by a command and pass them as arguments to another command?

How to name indistinguishable henchmen in a screenplay?

Fit odd number of triplets in a measure?

How do you write "wild blueberries flavored"?

Does the universe have a fixed centre of mass?

Was the pager message from Nick Fury to Captain Marvel unnecessary?

Determine whether an integer is a palindrome

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

What was the last profitable war?

Russian equivalents of おしゃれは足元から (Every good outfit starts with the shoes)



How to enable contextual substitutions in lstlisting?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Use Fira Code font with ligatures in code listingsContextual Alternatives in LuaLaTeXDefault value for basicstyle in lstlistinglstlisting: how to align highlighted codeHow to enable OpenType font features for Hangul?tex4ht and listings: lines don't break when using escapeinsideSubstitutions of initials by feature file, and mixing rulesDisplay available contextual swash/alternative etc. features of OpenType fonts through LuaTeXlstnewenvironment/lstset : using colors conditionally emph/emphstyle - SAS: (in=_x) versus if x in (1,2)How to make contextual substitutions work with luatex 1.0x?distinguishing forward and backward quote in lstlisting












0















Fira Code (available via its GitHub Release page) not only provides fancy programming ligatures (see Use Fira Code font with ligatures in code listings), but also contains contextual substitutions. For example, the colon character : is usually vertically aligned with respect to lowercase letters, so it will appear misaligned when it is placed between uppercase letters and/or lining numerals. But Fira Code, when Contextual Alternates is enabled, can substitute the lowercase-friendly : with an uppercase-friendly one.



The Contextual Alternates feature does not work in a lstlisting environment. For the ligatures, there is lstfiracode (shameless plug), but how can one get the rest of contextual substitutions as mentioned above?



documentclass{article}
usepackage{fontspec}
setmonofont{FiraCode-Regular.otf}[
Contextuals=Alternate
]
usepackage{listings}
lstset{basicstyle=ttfamily}
makeatletter
renewcommand*verbatim@nolig@list{}
makeatother
begin{document}
noindent
With verb|verbatim|:
begin{verbatim}
0xff 0xFF % x is contextually substituted
a-c A-C % - is contextually substituted
e+g 1+2 % + is contextually substituted
i*j 3*4 % * is contextually substituted
m:n 5:6 % : is contextually substituted
end{verbatim}
With verb|lstlisting|:
begin{lstlisting}
0xff 0xFF
a-c A-C
e+g 1+2
i*j 3*4
m:n 5:6
end{lstlisting}
end{document}


Contextual Alternates









share



























    0















    Fira Code (available via its GitHub Release page) not only provides fancy programming ligatures (see Use Fira Code font with ligatures in code listings), but also contains contextual substitutions. For example, the colon character : is usually vertically aligned with respect to lowercase letters, so it will appear misaligned when it is placed between uppercase letters and/or lining numerals. But Fira Code, when Contextual Alternates is enabled, can substitute the lowercase-friendly : with an uppercase-friendly one.



    The Contextual Alternates feature does not work in a lstlisting environment. For the ligatures, there is lstfiracode (shameless plug), but how can one get the rest of contextual substitutions as mentioned above?



    documentclass{article}
    usepackage{fontspec}
    setmonofont{FiraCode-Regular.otf}[
    Contextuals=Alternate
    ]
    usepackage{listings}
    lstset{basicstyle=ttfamily}
    makeatletter
    renewcommand*verbatim@nolig@list{}
    makeatother
    begin{document}
    noindent
    With verb|verbatim|:
    begin{verbatim}
    0xff 0xFF % x is contextually substituted
    a-c A-C % - is contextually substituted
    e+g 1+2 % + is contextually substituted
    i*j 3*4 % * is contextually substituted
    m:n 5:6 % : is contextually substituted
    end{verbatim}
    With verb|lstlisting|:
    begin{lstlisting}
    0xff 0xFF
    a-c A-C
    e+g 1+2
    i*j 3*4
    m:n 5:6
    end{lstlisting}
    end{document}


    Contextual Alternates









    share

























      0












      0








      0








      Fira Code (available via its GitHub Release page) not only provides fancy programming ligatures (see Use Fira Code font with ligatures in code listings), but also contains contextual substitutions. For example, the colon character : is usually vertically aligned with respect to lowercase letters, so it will appear misaligned when it is placed between uppercase letters and/or lining numerals. But Fira Code, when Contextual Alternates is enabled, can substitute the lowercase-friendly : with an uppercase-friendly one.



      The Contextual Alternates feature does not work in a lstlisting environment. For the ligatures, there is lstfiracode (shameless plug), but how can one get the rest of contextual substitutions as mentioned above?



      documentclass{article}
      usepackage{fontspec}
      setmonofont{FiraCode-Regular.otf}[
      Contextuals=Alternate
      ]
      usepackage{listings}
      lstset{basicstyle=ttfamily}
      makeatletter
      renewcommand*verbatim@nolig@list{}
      makeatother
      begin{document}
      noindent
      With verb|verbatim|:
      begin{verbatim}
      0xff 0xFF % x is contextually substituted
      a-c A-C % - is contextually substituted
      e+g 1+2 % + is contextually substituted
      i*j 3*4 % * is contextually substituted
      m:n 5:6 % : is contextually substituted
      end{verbatim}
      With verb|lstlisting|:
      begin{lstlisting}
      0xff 0xFF
      a-c A-C
      e+g 1+2
      i*j 3*4
      m:n 5:6
      end{lstlisting}
      end{document}


      Contextual Alternates









      share














      Fira Code (available via its GitHub Release page) not only provides fancy programming ligatures (see Use Fira Code font with ligatures in code listings), but also contains contextual substitutions. For example, the colon character : is usually vertically aligned with respect to lowercase letters, so it will appear misaligned when it is placed between uppercase letters and/or lining numerals. But Fira Code, when Contextual Alternates is enabled, can substitute the lowercase-friendly : with an uppercase-friendly one.



      The Contextual Alternates feature does not work in a lstlisting environment. For the ligatures, there is lstfiracode (shameless plug), but how can one get the rest of contextual substitutions as mentioned above?



      documentclass{article}
      usepackage{fontspec}
      setmonofont{FiraCode-Regular.otf}[
      Contextuals=Alternate
      ]
      usepackage{listings}
      lstset{basicstyle=ttfamily}
      makeatletter
      renewcommand*verbatim@nolig@list{}
      makeatother
      begin{document}
      noindent
      With verb|verbatim|:
      begin{verbatim}
      0xff 0xFF % x is contextually substituted
      a-c A-C % - is contextually substituted
      e+g 1+2 % + is contextually substituted
      i*j 3*4 % * is contextually substituted
      m:n 5:6 % : is contextually substituted
      end{verbatim}
      With verb|lstlisting|:
      begin{lstlisting}
      0xff 0xFF
      a-c A-C
      e+g 1+2
      i*j 3*4
      m:n 5:6
      end{lstlisting}
      end{document}


      Contextual Alternates







      fonts listings opentype





      share












      share










      share



      share










      asked 2 mins ago









      Ruixi ZhangRuixi Zhang

      5,818424




      5,818424






















          0






          active

          oldest

          votes












          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%2f485981%2fhow-to-enable-contextual-substitutions-in-lstlisting%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485981%2fhow-to-enable-contextual-substitutions-in-lstlisting%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

          Can't compile dgruyter and caption packagesLaTeX templates/packages for writing a patent specificationLatex...

          Schneeberg (Smreczany) Bibliografia | Menu...

          Hans Bellmer Spis treści Życiorys | Upamiętnienie | Przypisy | Bibliografia | Linki zewnętrzne |...