Грамотный подход к листингам не работает для каждого товара

Грамотный подход к листингам не работает для каждого товара

Я воспроизводю стиль кода C с листингами. Я определил ""как строку, поэтому, когда я добавляю библиотеки, "ff.h"она обрабатывается как строка и печатается синим цветом. Чтобы этого избежать, я использую literate.

Пример этого:

\documentclass[11pt,fleqn]{article} 

\usepackage[dvipsnames]{xcolor} 

\usepackage{listings}

\lstdefinestyle{styleC}{
  language = C,
  commentstyle = {\color{ForestGreen}},
  stringstyle = {\color{NavyBlue}},
  comment = [l]{//},
  morecomment = [s]{/*}{*/},
  morestring = [b]',
  morestring = [b]",   
}

\lstnewenvironment{C}{
  \lstset{
    style=styleC,
    frame=single,
    literate = {"ff.h"}{"ff.h"}6 {"math.h"}{"math.h"}8 
    }
  }
  {}
  
  
\begin{document}
  
\begin{C}
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <complex.h>
#include "ff.h"
#include "ffconf.h"
#include "math.h"
#include "arm_math.h"
#include "audioMoth.h"
\end{C}

\end{document}

с правильным результатом: введите описание изображения здесь

Но когда я применил это ко всем библиотекам:

literate = {"ff.h"}{"ff.h"}6 {"ffconf.h"}{"ffconf.h"}10 {"math.h"}{"math.h"}8   {"arm_math.h"}{"arm_math.h"}12 {"audioMoth.h"}{"audioMoth.h"}13 

результат следующий:

введите описание изображения здесь

Что может происходить?

решение1

Если числа больше 9, их необходимо заключать в скобки:

\documentclass[11pt,fleqn]{article}

\usepackage[dvipsnames]{xcolor}

\usepackage{listings}

\lstdefinestyle{styleC}{
  language = C,
  commentstyle = {\color{ForestGreen}},
  stringstyle = {\color{NavyBlue}},
  comment = [l]{//},
  morecomment = [s]{/*}{*/},
  morestring = [b]',
  morestring = [b]",
}

\lstnewenvironment{C}{
  \lstset{
    style=styleC,
    frame=single,
    %literate = {"ff.h"}{"ff.h"}6 {"math.h"}{"math.h"}8
    literate = {"ff.h"}{"ff.h"}6 {"ffconf.h"}{"ffconf.h"}{10} {"math.h"}{"math.h"}8   {"arm_math.h"}{"arm\_math.h"}{12} {"audioMoth.h"}{"audioMoth.h"}{13}
    }
  }
  {}


\begin{document}

\begin{C}
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <complex.h>
#include "ff.h"
#include "ffconf.h"
#include "math.h"
#include "arm_math.h"
#include "audioMoth.h"
\end{C}

\end{document}

Связанный контент