我试图minted
在 中安装包TeXLive
。我安装了它然后运行sudo tlmgr update --all
。它运行缓慢,所以我在终端Ctrl+Z
中停止了它ubuntu
,然后运行sudo tlmgr update --list
。之后我安装了texlive-latex-extra
。python-pygments
稍后我sudo tlmgr update --all
再次运行并让它完成。
之后我尝试使用listings
希腊语运行一个简单的代码,但出现错误
错误字符代码 (256)
说明该问题的 MWE 如下
\documentclass{book}
\usepackage[english,greek]{babel}
\usepackage[iso-8859-7]{inputenc}
% %\usepackage[utf8]{inputenc}
\usepackage{kerkis}
\usepackage{pifont}
% %
\newcommand{\sw}{\selectlanguage{english}}
\newcommand{\sq}{\selectlanguage{greek}}
\newcommand{\eng}[1]{\latintext#1\greektext}
\newcommand{\gre}[1]{\greektext#1\latintext}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{textcomp}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\lstdefinestyle{JavaStyle}{
backgroundcolor=\color{lbcolor},
tabsize=4,
% rulecolor=,
language=Java, % choose the language of the code
basicstyle=\scriptsize, % the size of the fonts that are used for the code
upquote=true,
aboveskip={1.5\baselineskip},
columns=fixed,
showstringspaces=false,
extendedchars=false,
breaklines=true,
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
numbers=left,
showtabs=false,
showspaces=false,
showstringspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
%commentstyle=\color[rgb]{0.026,0.112,0.095},
commentstyle=\itshape\color{green!40!black},
stringstyle=\itshape\color{red!90!black},
numberstyle=\itshape\color{yellow!50!black}
}
\lstdefinestyle{CppStyle}{
backgroundcolor=\color{lbcolor},
tabsize=4,
% rulecolor=,
language=C++, % choose the language of the code
basicstyle=\scriptsize, % the size of the fonts that are used for the code
upquote=true,
aboveskip={1.5\baselineskip},
columns=fixed,
showstringspaces=false,
extendedchars=false,
breaklines=true,
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
numbers=left,
showtabs=false,
showspaces=false,
showstringspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
%commentstyle=\color[rgb]{0.026,0.112,0.095},
commentstyle=\itshape\color{green!40!black},
stringstyle=\itshape\color{red!90!black},
numberstyle=\itshape\color{yellow!50!black}
}
\begin{document}
This is a dummy text. kjhbki
\end{document}
该.aux
文件称
\relax
\select@language{greek}
\@writefile{toc}{\select@language{greek}}
\@writefile{lof}{\select@language{greek}}
\@writefile{lot}{\select@language{greek}}
虽然.log
可以找到该文件这里
知道为什么会发生这种情况以及如何解决它吗?请注意,如果我删除序言listings
,删除所有生成的文件并构建文档,则一切都会正常进行。
答案1
更新
babel-greek
该问题已在 2015/11/27 发布的 1.9e 版本中修复
原始答案
这是一个临时修复,如果希腊语是最后加载的语言,它应该会起作用;它只是将 的值恢复\@tempcnta
为listings
未加载时的值。但是,这是 中的一个错误babel-greek
:任何包都不应依赖于 的任何特定值\@tempcnta
;我的印象是添加了一些无用的代码。
\documentclass{article}
\usepackage[greek]{babel}
\usepackage{listings}
\makeatletter
\AtBeginDocument{%
\expandafter\def\expandafter\originalTeX\expandafter{%
\expandafter\@tempcnta\number253\expandafter\relax\originalTeX}%
}
\makeatother
\begin{document}
a
\end{document}
错误代码位于第 376 行,greek.ldf
内容是
376 \babel@savevariable{\lccode\@tempcnta}\lccode\@tempcnta=\@tempcnta
虽然应该
376 \expandafter\babel@savevariable\expandafter{\expandafter\lccode\the\@tempcnta}\lccode\@tempcnta=\@tempcnta
所以正确的指示
\babel@savevariable{\lccode128}
\babel@savevariable{\lccode129}
...
\babel@savevariable{\lccode252}
而不是多次执行无用(和错误)
\babel@savevariable{\lccode\@tempcnta}
因此,更好的临时解决办法是
\documentclass{article}
\usepackage[greek]{babel}
\usepackage{listings}
\makeatletter
% Avoid the spurious error
\AtBeginDocument{%
\expandafter\def\expandafter\originalTeX\expandafter{%
\expandafter\@tempcnta\number253\expandafter\relax\originalTeX}%
}
% apply the fix
\addto\extrasgreek{%
\@tempcnta=128
\@whilenum\@tempcnta<253\do{%
\expandafter\babel@savevariable\expandafter{\expandafter\lccode\the\@tempcnta}%
\lccode\@tempcnta=\@tempcnta
\advance\@tempcnta\@ne
}%
}
\makeatother
\begin{document}
a
b
\end{document}
答案2
(太长,无法发表评论)。这是 Babel 的一个错误。它依赖于临时计数器,当 listings 将其设置为时会失败256
:
\documentclass{book}
\usepackage[english,greek]{babel}
\begin{document}
\makeatletter
\@tempcnta=256
\selectlanguage{greek}
\end{document}
向 babel 维护者或者维护者发送错误报告babel-greek
。