1

I am using package listings for JSON data. I am following this example How to improve listings display of JSON files from this stackexchange answer. It generates the following output: enter image description here I added caption to the listing using:

\begin{lstlisting}[language=json,firstnumber=1,caption={My Caption},captionpos=b]

I want to make the listing look like this:

enter image description here

  • The line numbers are in grey color and smaller font
  • The keys are in bold font and black color, the quotes of the keys are not bold
  • The values colors are based on their data type: string→green (with quotes green too), number→red, boolean→cyan, float→blue etc.

I can change the color of brackets, colon, and comma, and the font is fine too, but i am struggling with the keys and values formatting and line numbers color & size. Any help will be highly appreciated.

3
  • You might have more luck with minted and its styles…
    – TeXnician
    Aug 31 '20 at 14:10
  • @TeXnician Could you please give me some guideline or links about minted which achieves the things i need?
    – Raja Ayaz
    Aug 31 '20 at 15:26
  • Unfortunately, I have no time to spell it out. But Pygments (the tool behind minted) has very good lexers which do most of the work for you. If none of the many predefined styles match your taste (because of the very strict requirements) you can overwrite a few of the default commands. Maybe someone else will be able to solve your problem with listings :)
    – TeXnician
    Aug 31 '20 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.