列出 LuaLaTeX 中的软件包问题,并在 UTF 中对西里尔文注释进行着色

列出 LuaLaTeX 中的软件包问题,并在 UTF 中对西里尔文注释进行着色

在 LuaLaTeX 中,彩色西里尔文注释不起作用。

我怎样才能解决这个问题?

梅威瑟:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=modern]{russian}
\setotherlanguage{english}
\defaultfontfeatures{Ligatures={TeX}}
\setmainfont{Times New Roman}
\newfontfamily{\cyrillicfont}{Times New Roman}
\setsansfont{Arial}
\newfontfamily{\cyrillicfontsf}{Arial}
\setmonofont{Courier New}
\newfontfamily\cyrillicfonttt[Script=Cyrillic]{Courier New}
\usepackage{xcolor}
%\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\usepackage{listings}
\lstloadlanguages{SQL}

\lstdefinelanguage{SQL}
{
    keywords={create, replace, table, primary, foreign, references, key, not, null, select, insert, update, where, from, as, into, values, set, delete, order, by, and, distinct, max, min, group, having, count, left, right, full, join, on, union, plan, collate, all, returns, procedure, begin, end, suspend, generator, to, or, each, execute, row, statement, active, trigger, for, before, after, is, if, then, new, old, gen_id, position, inactive, grant, revoke, with, option, public, domain, collation, character, translation, usage, cascade, restrict, sequence, increment, minvalue, maxvalue, start, function, default, nextval, currval},
    keywordstyle=\color{darkblue},
    ndkeywords={varchar, integer, smallint, char},
    ndkeywordstyle=\color{cyan},
    sensitive=false,
    morecomment=[l]--,
    morecomment=[s][\color{orange}]{/*}{*/},
    morestring=[d]',
    morestring=[d]",
    stringstyle=\color{purple}
}

\lstdefinestyle{listSQL}{
%   extendedchars=true,
%   extendedchars=\true,
    language=SQL,
    belowcaptionskip=5pt,
    xleftmargin=0.5cm,
    numbers=left,
    numberstyle=\small,
    frame=single,
    keepspaces=true,
    breaklines=true,
    breakatwhitespace=true,
    breakindent=0pt,
    emph={},
    emphstyle=\color{red},
    basicstyle=\ttfamily,
    columns=fullflexible,
    showstringspaces=false,
    commentstyle=\color{orange}\upshape}

\begin{filecontents*}[overwrite]{dbstart.txt}
    -- Create table sgroup
    create table sgroup (
    id integer not null,
    group_name varchar(40),
    primary key (id));  -- уникальный ключ id
    -- Создаем таблицу Студент
    create table student (
    id integer not null,
    id_group integer not null, -- поле для связи с таблицей Группа
    student_name varchar(40),
    last_name varchar(40),
    middle_name varchar(40),
    sex char(1),
    age smallint,
    primary key (id), -- уникальный ключ id
    foreign key (id_group) references sgroup (id)); -- определение связи с таблицей Группа
    -- Создаем таблицу Хобби
    create table hobby (
    id integer not null, -- уникальный ключ
    hobby_name varchar(100),
    primary key (id)); -- уникальный ключ id
    -- Создаем таблицу Студент-Хобби
    create table student_hobby (
    id_student integer not null, -- поле для связи с таблицей Студент
    id_hobby integer not null, -- поле для связи с таблицей Хобби
    primary key (id_student, id_hobby), -- уникальный ключ составной id_student, id_hobby
    foreign key (id_hobby) references hobby (id), -- определение связи с таблицей Хобби
    foreign key (id_student) references student (id)); -- определение связи с таблицей Студент
\end{filecontents*}

\begin{document}
    In string: \lstinline[style=listSQL] !select count(*) from sgroup; -- выборка! !
    \lstinputlisting[label=dbstart, style=listSQL]{dbstart.txt}
\end{document}

在此处输入图片描述

答案1

使用minted包。

采用默认设置的示例:

\inputminted{SQL}{dbstart.txt}

铸造

平均能量损失

\documentclass{article}
\usepackage{xcolor}
%\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=modern]{russian}
\setotherlanguage{english}
\defaultfontfeatures{Ligatures={TeX}}
\setmainfont{Times New Roman}
\newfontfamily{\cyrillicfont}{Times New Roman}
\setsansfont{Arial}
\newfontfamily{\cyrillicfontsf}{Arial}
\setmonofont{Courier New}
\newfontfamily\cyrillicfonttt[Script=Cyrillic]{Noto Sans Mono}
\usepackage{minted}

\usepackage{listings}
\lstset{escapebegin=\begin{russian},escapeend=\end{russian}}
\lstloadlanguages{SQL}

\lstdefinelanguage{SQL}
{
    keywords={create, replace, table, primary, foreign, references, key, not, null, select, insert, update, where, from, as, into, values, set, delete, order, by, and, distinct, max, min, group, having, count, left, right, full, join, on, union, plan, collate, all, returns, procedure, begin, end, suspend, generator, to, or, each, execute, row, statement, active, trigger, for, before, after, is, if, then, new, old, gen_id, position, inactive, grant, revoke, with, option, public, domain, collation, character, translation, usage, cascade, restrict, sequence, increment, minvalue, maxvalue, start, function, default, nextval, currval},
    keywordstyle=\color{darkblue},
    ndkeywords={varchar, integer, smallint, char},
    ndkeywordstyle=\color{cyan},
    sensitive=false,
    morecomment=[l]--,
    morecomment=[s][\color{orange}]{/*}{*/},
    morestring=[d]',
    morestring=[d]",
    stringstyle=\color{purple}
}

\lstdefinestyle{listSQL}{
%   extendedchars=true,
%   extendedchars=\true,
    language=SQL,
    belowcaptionskip=5pt,
    xleftmargin=0.5cm,
    numbers=left,
    numberstyle=\small,
    frame=single,
    keepspaces=true,
    breaklines=true,
    breakatwhitespace=true,
    breakindent=0pt,
    emph={},
    emphstyle=\color{red},
    basicstyle=\ttfamily,
    columns=fullflexible,
    showstringspaces=false,
    commentstyle=\color{orange}\upshape}

\begin{filecontents*}[overwrite]{dbstart.txt}
    -- Create table sgroup
    create table sgroup (
    id integer not null,
    group_name varchar(40),
    primary key (id));  -- уникальный ключ id
    -- Создаем таблицу Студент
    create table student (
    id integer not null,
    id_group integer not null, -- поле для связи с таблицей Группа
    student_name varchar(40),
    last_name varchar(40),
    middle_name varchar(40),
    sex char(1),
    age smallint,
    primary key (id), -- уникальный ключ id
    foreign key (id_group) references sgroup (id)); -- определение связи с таблицей Группа
    -- Создаем таблицу Хобби
    create table hobby (
    id integer not null, -- уникальный ключ
    hobby_name varchar(100),
    primary key (id)); -- уникальный ключ id
    -- Создаем таблицу Студент-Хобби
    create table student_hobby (
    id_student integer not null, -- поле для связи с таблицей Студент
    id_hobby integer not null, -- поле для связи с таблицей Хобби
    primary key (id_student, id_hobby), -- уникальный ключ составной id_student, id_hobby
    foreign key (id_hobby) references hobby (id), -- определение связи с таблицей Хобби
    foreign key (id_student) references student (id)); -- определение связи с таблицей Студент
\end{filecontents*}

\begin{document}
%    In string: \lstinline[style=listSQL] !select count(*) from sgroup; -- выборка! !
%    \lstinputlisting[label=dbstart, style=listSQL]{dbstart.txt}
%    
\inputminted{SQL}{dbstart.txt}.
            
\end{document}

有许多可能的选项和定制。

例如,随机内置样式(algol)和breaklines选项:

\usemintedstyle[SQL]{algol}
\inputminted[breaklines]{SQL}{dbstart.txt}.

阿尔戈尔风格

相关内容