2

I want to change how text in footnotes and quotes appears in the editor of TeXstudio. I actually want two related things. The first is that when I enter a quote environment, I want the text to appear in gray, much like text in an equation environment already appears green. The second is that I also want text in footnotes to appear gray. So when I type \footnote{example text}, the example text between brackets appears gray.

Is this possible? I tried searching for the answer and found some contradictory answers to queries that were related but not entirely similar to my request.

1 Answer 1

1

This can be solved by adding your own language definition to TeXstudio, which is not all that straightforward.

What you need to do is copy the tex.qnfa file in github and add it in the language folder of your config directory. Change the second line of the code in the file to:

<QNFA language="(La)TeX footnote" extensions="tex;sty;cls;ins;cfg;ltx;lytex;tikz;pdf_tex;ctx" defaultLineMark="">

This ensures that you create a new language called "(La)TeX footnote". Then add the following lines to the code:

  <!-- ========================= FOOTNOTES ====================== -->

    <context id="footnote" format="asymptote:block" transparency="true">
            <start parenthesis="footnote:open" parenthesisWeight="20" format="keyword">\\footnote{</start>
        <stop parenthesis="footnote:close" parenthesisWeight="20" format="keyword">\}</stop>
        <context id="substring" format="asymptote:numbers" transparency="true">
            <start parenthesis="curly2:open">{</start>
            <stop parenthesis="curly2:close">}</stop>
        </context>
        <embed target="(La)TeX footnote" />
    </context>

I placed it under SECTIONS, but I doubt it matters. Finally open up TeXstudio, go to view -> highlighting and select "(La)TeX footnote"

The strings after format determine the formatting of the footnote. I used asymptote:block and asymptote:numbers for this because I never use those anyway and you can easily edit them in the syntax highlighting menu.

The extra nested <context id="substring" part ensures that the formatting does not change when you have nested commands in your footnotes. Please note that this only works for one layer of nesting. So \footnote{\Cite{bibkey} Extra footnote text} works as expected but \footnote{\textit{\textbf{text}} additional text} will stop working after the second right bracket and the additional text will be shown without footnote formatting. If you do have nested commands within your nested commands, you need to add a seconded nested <context id.

Finally the line <embed target="(La)TeX footnote" /> makes sure that there is keyword matching within the footnote. If you do not want that, remove this line.

I have no idea what parenthesisWeight and transparency do, but I got it to work, so I left them in.

As I mentioned, it is a bit hacky and the result is not as elegant as I'd like, but it works for now until hopefully this feature is added.

You must log in to answer this question.

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